<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dominik Broj on Medium]]></title>
        <description><![CDATA[Stories by Dominik Broj on Medium]]></description>
        <link>https://medium.com/@brojd?source=rss-2299e291a69a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xGx6F6tefZAttYB31dknpw.jpeg</url>
            <title>Stories by Dominik Broj on Medium</title>
            <link>https://medium.com/@brojd?source=rss-2299e291a69a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:35:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brojd/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Our journey to improve Grafana Assistant dashboarding mode]]></title>
            <link>https://medium.com/grafana-labs/our-journey-to-improve-grafana-assistant-dashboarding-mode-66571dde23a1?source=rss-2299e291a69a------2</link>
            <guid isPermaLink="false">https://medium.com/p/66571dde23a1</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[agent-observability]]></category>
            <dc:creator><![CDATA[Dominik Broj]]></dc:creator>
            <pubDate>Wed, 07 Oct 2026 18:54:09 GMT</pubDate>
            <atom:updated>2026-10-07T18:54:09.478Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How we used production telemetry, offline evaluations, and Grafana Agent Observability to cut error rate by 73%, latency p95 by 50%, and cost by 18%.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C7AVg-w_O4GzuCPxwK5xKQ.png" /></figure><p>Grafana Assistant lets you build dashboards using natural language. You can ask it to update a panel or variable, or reorganize the grid layout, and the changes appear directly on your screen.</p><p>This happens in what we call <strong>dashboarding mode</strong>. When your request involves a dashboard, Assistant switches into this mode, which brings its own instructions and tools for reading and editing the dashboard in front of you, or creating a new one.</p><p>You no longer need to memorize query syntax for different databases or calculate pixel coordinates for panel placement. If the data exists in your Grafana instance, you describe what you want to see, and <a href="https://grafana.com/docs/grafana-cloud/platform/grafana-assistant/"><strong>Grafana Assistant</strong></a> handles the rest.</p><p>This broke down barriers for new <a href="https://grafana.com/products/cloud/">Grafana Cloud</a> users and sped up timelines for experienced users, so it’s no wonder people adopted it quickly. By mid-2026, <strong>27% of all user conversations</strong> in Assistant ran in dashboarding mode, making it one of our most popular capabilities.</p><p>With all that increased usage we received tons of valuable feedback.</p><p>People loved the magic when it worked, but they were also very clear about the rough edges: occasionally, it could be slow, consume a significant amount of tokens, or simply make mistakes — for example rearranged panels when it shouldn’t have. Users who experienced this asked for <strong>faster responses</strong>, <strong>higher reliability</strong>, and <strong>better token efficiency</strong>.</p><p>In early June, we pulled together a focused <a href="https://grafana.com/blog/tiger-teams-how-we-tackle-urgent-cross-functional-challenges-at-grafana-labs/">tiger team</a> to address it.</p><p>Spoiler here! This is what we achieved by mid-August:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kxouqF4pY0Hb9mnKACGMSw.png" /></figure><p>Total traffic jumped by 18.5% while decreasing the token usage, the <strong>error rate dropped by nearly 75%</strong>, and our <strong>p95 latency was cut in half</strong>.</p><p>Those improvements didn’t come from just a few pull requests. They came from a number of steady daily improvements over 10 weeks.</p><p>Here is what happened behind the scenes, what we changed, and how we measured it.</p><h3>Don’t guess: instrument first</h3><p>When an AI agent misbehaves in production, it’s tempting to go straight to tweaking the harness.</p><p>You edit the system prompt, add five more examples, reword your tool descriptions, and test on your local environment. Looks good? Ship it.</p><p>That approach is a trap.</p><p>Without baseline telemetry, tweaking an agent is like fighting ghosts in the dark. You change a sentence to fix a row-ordering bug, and you silently break three-column layouts somewhere else. You end up trading one failure mode for another without realizing it — yet.</p><p>We decided to treat our agent like any other distributed production service: <strong>instrument first</strong>, <strong>establish a baseline</strong>, and <strong>write code only when you can measure the result</strong>.</p><p>We turned to our own tool for the job:<a href="https://grafana.com/docs/grafana-cloud/observe-and-act/agent-observability/"> Grafana Agent Observability</a>.</p><p>Agent Observability runs on OpenTelemetry and captures every model generation, tool invocation, token count, and cost across live environments. We combined production monitoring with an internal offline evaluation suite named llmspec:</p><ul><li><strong>Production telemetry and online evaluations in Agent Observability.</strong> Every production conversation emits OpenTelemetry spans alongside gen_ai.* attributes. We configured online evaluators to score live interactions against quality criteria, catching failed tool calls and format errors as they happened.</li><li><strong>Offline scenario benchmarks in </strong><strong>llmspec.</strong> We built an automated test suite where each scenario is defined in a simple YAML file. Each test runs against an active Grafana instance through the browser frontend environment, testing the exact code paths user requests take. The runner checks whether the resulting dashboard matches the desired state, then exports the run as an offline experiment into Agent Observability so we can compare multiple runs side by side.</li></ul><p>With both in place, our baseline was set. We knew our exact p50 and p95 latencies, our cost per interaction, and the specific failure patterns our users were unhappy with.</p><p>Now we were ready to start fixing things.</p><h3>Turning production bugs into permanent test cases</h3><p>Big reliability gains rarely come from one eureka moment, and these gains were not an exception. They came from running the same loop over and over:</p><ol><li><strong>Find a concrete failure</strong> in<a href="https://grafana.com/docs/grafana-cloud/observe-and-act/agent-observability/"> Agent Observability</a>, such as an unhandled tool error or a conversation flagged by an online evaluator.</li><li><strong>Convert that exact failure</strong> into a reproducible llmspec scenario file.</li><li><strong>Fix the underlying issue</strong> in the agent code, tool implementation, or schema validation until the scenario passes.</li><li><strong>Deploy the update behind a feature flag</strong> and verify in Agent Observability that the error vanished from production telemetry.</li></ol><p>Our project Slack channel quickly settled into a routine. A typical message from our engineers looked like this:</p><p><em>“Saw an issue in Agent Observability around combining existing dashboards into new tabbed one (link here). Reproduced it in </em><em>llmspec scenario </em><em>100-combine-into-new-tabbed-dashboard. PR #1842 fixes it. Ran the full </em><em>llmspec suite including the new scenario, all good.”</em></p><p>Our dashboarding scenario catalog has grown from <strong>78 test cases in June to nearly 150 by mid-August</strong>.</p><p>Every edge case reported by a user turned into a permanent regression test in CI. If a bug happened once, the system learned never to allow it again.</p><h3>Simpler is better</h3><p>Beyond patching individual bugs, we took a holistic look at the underlying architecture of dashboarding mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6-pfJ35oS88HJWj5G_ArA.png" /><figcaption>An example of dashboarding mode in Grafana Assistant</figcaption></figure><p>Our original setup seemed logical at first. We gave an agent a suite of specialized, imperative micro-tools:</p><ul><li>A tool to manage panels, complete with its own operation vocabulary and an arbitrary cap of ten operations per call</li><li>A tool to manage grid layout, containing 11 distinct operation types</li><li>Separate tools for template variables, annotations, dashboard metadata, and document reads</li></ul><p>Over time, that design became questionable for several reasons:</p><ul><li><strong>Artificial constraints on capable models.</strong> As models improved, narrow tools that were too specific boxed them in. The agent spent its energy squeezing intent into our rigid, custom operations rather than solving the user’s problem.</li><li><strong>Developer maintenance overhead.</strong> Maintaining a suite of bespoke tools pushed the engineering burden in the wrong direction. We were writing and debugging translation layers, schema mappers, and edge cases instead of letting the model do what it was already good at.</li><li><strong>Token usage.</strong> Six distinct tool definitions with detailed parameter schemas burned thousands of tokens on every single turn.</li></ul><p>We decided to try a completely different approach: <strong>give the agent the dashboard’s native JSON document and let it edit that directly</strong>.</p><p>Grafana dashboards already possess a canonical specification: the<a href="https://grafana.com/docs/grafana-cloud/visualizations/dashboards/"> Grafana dashboard schema</a>. It supports rows, tabs, responsive auto-grids, and conditional display rules. Frontier models have already seen thousands of Grafana dashboard configurations in public repositories and documentation.</p><p>Instead of a set of imperative tools dictating every action, we reduced the number of tools and made them much more generic. We shifted the interaction model to treat the dashboard specification like <strong>source code</strong>.</p><p>Much like a coding agent inspects and modifies code files, the agent reads slices of the dashboard JSON and applies targeted edits directly to the document.</p><p>Under the hood, these tools connect directly to DashboardMutationAPI, Grafana’s frontend API to manipulate live dashboards. It uses the same serialization, migration, and validation pipeline that powers the Grafana web interface.</p><h3>Keeping the context window lean</h3><p>The obvious objection here is context window consumption. A production dashboard with 40 panels, complex thresholds, and nested queries can easily consume 40,000 tokens of JSON. If an agent reads and rewrites the entire document on every turn, it runs out of context space in two exchanges.</p><p>We solved this by designing our tools around <strong>partial updates</strong>:</p><ul><li>The model sends only the modified, added, or deleted fragments.</li><li>Behind the scenes, the tool fetches the current dashboard specification from core, merges the model’s patch into the tree, runs core schema validation, and saves the document.</li><li>Instead of dumping 50 kilobytes of JSON back into the chat history, the tool responds with a short summary of what changed (for example: &quot;Added panel ‘CPU Usage&#39; to row ‘Compute’&quot; ).</li></ul><p>We gave read operations the same treatment. Instead of pulling down the whole dashboard at once, the agent uses <strong>targeted reads and bounded searches</strong> to inspect only the panels or variables relevant to the immediate task.</p><h3>Stop fighting what the model already knows</h3><p>During early testing, the agent kept formatting dashboard components in ways that clashed with our custom tool schemas.</p><p>When we investigated why, it turned out the model was relying on the official Grafana dashboard formats it had already absorbed from thousands of public GitHub repositories and documentation pages during pre-training. Modern frontier models already arrived with Grafana’s native structure baked into their weights.</p><p>Our custom schema was fighting the model’s pre-trained knowledge, and the model was winning. That friction created errors and unnecessary token usage on its own.</p><p>So we started deleting.</p><p>We removed large blocks of prompt instructions that explained how to structure dashboards. Then we removed detailed datasource schema guides from the prompt. Instead of trying to teach every formatting rule in advance, we let the backend validate the model’s input and return a clear error whenever a field was invalid.</p><p>It still happens that the agent makes a mistake, but then it spends one extra turn reading the error message and fixing its edit. In the everyday scenario, the prompt is thousands of tokens lighter, responses are faster, and the run is cheaper.</p><p>With strict validation, the agent’s ability to correct its own mistakes has improved. Previously, if the agent produced an invalid configuration, the system often failed silently, leaving users with broken panels or missing data. With clear validation errors returned directly to the agent, the model caught its own mistakes and corrected them before finishing the response.</p><p>There is also a broader takeaway here: <strong>If you want language models to work well with your product,</strong> <strong>publish your data formats openly</strong>. Put schemas, example configurations, and guides in public view. A format that ships without public examples is a format the next model generation will not know how to handle.</p><h3>Practical rules for building production agents</h3><p>If your team is building tool-using agents for your software product, here are seven principles we took away from this project:</p><ol><li><strong>Instrument before you optimize.</strong> Spending time setting up<a href="https://grafana.com/docs/grafana-cloud/observe-and-act/agent-observability/"> Grafana Agent Observability</a> and an offline evaluation harness felt like a delay at the start. It turned out to be the foundation for every good decision we made, replacing endless debates about prompts with cold evidence.</li><li><strong>A 100% eval pass rate means your tests are broken.</strong> When our test suite hit 100% in July, it did not indicate perfection; it meant our scenarios were too easy. We spent the next month writing harder scenarios extracted directly from production failures.</li><li><strong>Prefer fewer, more generic tools.</strong> Micro-tools describing every granular operation on an object cost significantly more in token overhead and might limit the model’s capabilities.</li><li><strong>Discover what the model already knows, then stop paying for it.</strong> If frontier models have already absorbed your schema from public data, delete your redundant prompt explanations and let the weights do the work.</li><li><strong>Convert silent failures into loud, informative errors.</strong> A schema validator that rejects invalid input with an explanatory error gives the model an immediate opportunity to self-correct. Silent fallbacks just deliver broken states to users.</li></ol><h3>Try it out</h3><p>Dashboarding mode is available today in Grafana Assistant across all Grafana Cloud tiers, including the<a href="https://grafana.com/pricing/"> Grafana Cloud Free tier</a>. Open the Assistant drawer, describe the panels or dashboards you need, and see how it builds them.</p><p>If your team is building LLM agents of your own and wants complete visibility into generations, token consumption, latency, and quality evaluations, take a look at<a href="https://grafana.com/docs/grafana-cloud/observe-and-act/agent-observability/"> Grafana Agent Observability</a>. With SDKs for Go, Python, TypeScript, Java, and .NET, it gives you the tracing, online evaluators, and offline experiment tooling needed to take the guesswork out of shipping AI agents to production.</p><p>Or try it out yourself! Build something fun and let us know. It’s now accessible and intuitive also for nontechnical users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66571dde23a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/grafana-labs/our-journey-to-improve-grafana-assistant-dashboarding-mode-66571dde23a1">Our journey to improve Grafana Assistant dashboarding mode</a> was originally published in <a href="https://medium.com/grafana-labs">Unprompted, by Grafana Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate loading statuses in MobX]]></title>
            <link>https://medium.com/@brojd/automate-loading-statuses-in-mobx-d6965ad738d9?source=rss-2299e291a69a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6965ad738d9</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[mobx]]></category>
            <category><![CDATA[asynchronous]]></category>
            <dc:creator><![CDATA[Dominik Broj]]></dc:creator>
            <pubDate>Fri, 10 Nov 2023 23:01:06 GMT</pubDate>
            <atom:updated>2023-11-14T09:54:08.284Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scenario</h3><p>Let’s consider projects that don’t follow optimistic updates and don’t use tools like react-query , SWR or similar but instead prefer to handle data fetching and loading statuses within MobX.</p><h3>What usually happens</h3><p>In such cases handling async code in MobX is often done in one of the 2 ways:</p><p>1. By manually setting local loading flags that live in the same store as the retrieved domain data:</p><pre>// domain store<br>class TodosStore {<br>  todos: Todo[] = [];<br>  getTodosLoadingStatus?: LoadingStatus;<br>  getTodosError?: string;<br><br>  constructor() {<br>    makeAutoObservable(this, {}, { autoBind: true });<br>  }<br><br>  async getAllTodos() {<br>    this.getTodosLoadingStatus = &#39;loading&#39;;<br>    try {<br>      const todos = await getAllTodos();<br>      runInAction(() =&gt; {<br>        this.todos = todos;<br>        this.getTodosLoadingStatus = &#39;success&#39;;<br>      });<br>    } catch (error) {<br>      this.getTodosError = (error as Error).message;<br>      this.getTodosLoadingStatus = &#39;error&#39;;<br>    }<br>  }<br>}<br><br>// somewhere in component<br>...<br>const { todos: { getTodosLoadingStatus } } = useStore();<br>return &lt;Button isLoading={getTodosLoadingStatus === &#39;loading&#39;} /&gt;</pre><p>2. By manually setting loading flags that live in a common store that is used by different domains:</p><pre>// common store<br>export default class CommonStore {<br>  loadingStatuses: Record&lt;ActionKey, LoadingStatus&gt; = {};<br>  errors: Record&lt;ActionKey, string&gt; = {};<br><br>  constructor(rootStore: RootStore) {<br>    makeAutoObservable(this, {}, { autoBind: true });<br>  }<br><br>  setLoadingStatus(actionKey: ActionKey, status: LoadingStatus) {<br>    this.loadingStatuses[actionKey] = status;<br>  }<br><br>  setError(actionKey: ActionKey, error: string) {<br>    this.errors[actionKey] = error;<br>  }<br>}<br><br><br>// domain store<br>class TodosStore {<br>  todos: Todo[] = [];<br>  getTodosLoadingStatus?: LoadingState;<br>  getTodosError?: string;<br><br>  constructor(rootStore: RootStore) {<br>    this.rootStore = rootStore;<br>    makeAutoObservable(this, {}, { autoBind: true });<br>  }<br><br>  async getAllTodos() {<br>    this.rootStore.commonStore.setLoadingStatus(ActionKey.GetTodos, &#39;loading&#39;);<br>    try {<br>      const todos = await getAllTodos();<br>      runInAction(() =&gt; {<br>        this.todos = todos;<br>        this.rootStore.commonStore.setLoadingStatus(ActionKey.GetTodos, &#39;success&#39;);<br>      });<br>    } catch (error) {<br>      this.rootStore.commonStore.setError(ActionKey.GetTodos, `Couldn&#39;t fetch todos.`);<br>      this.rootStore.commonStore.setLoadingStatus(ActionKey.GetTodos, &#39;error&#39;); <br>    }<br>  }<br>}<br><br>// somewhere in component<br>...<br>const { common: { loadingStatuses } } = useStore();<br>return &lt;Button isLoading={loadingStatuses.getTodos === &#39;loading&#39;} /&gt;</pre><p>IMHO the first approach is far from ideal. Usually it ends up with inconsistent naming of the flags and it’s difficult to track all the loading / error states because they are spread across different domain stores in the codebase.</p><p>Second approach, when all the loading statuses and errors are centralized, is more convenient. It’s easy to assure consistency, look for specific loading flag / error, refactor and create abstractions that automate setting / retrieving them (e.g. useIsLoadingcustom hook, &lt;Loading /&gt;component that is reading data from a single store and so on).</p><h3>But we can do even better!</h3><p>What if loading states management for any async action is as simple as:</p><pre>// domain store<br>class TodosStore {<br>  todos: Todo[] = [];<br><br>  constructor() {<br>    makeAutoObservable(this, {}, { autoBind: true });<br>  }<br><br>  @AutoLoadingState(ActionKey.GetAllTodos) // &lt;------ crucial part here<br>  async getAllTodos() {<br>    const todos = await getAllTodos();<br>    runInAction(() =&gt; {<br>      this.todos = todos;<br>    });<br>  }<br><br>  @AutoLoadingState((todoId: string) =&gt; `${ActionKey.DeleteTodo}-${todoId}`) // &lt;---- format action key based on params<br>  async deleteTodo(todoId: string) {<br>    await deleteTodo(todoId);<br>    runInAction(() =&gt; {<br>      const idx = this.todos.findIndex(({ id }) =&gt; id === todoId);<br>      this.todos.splice(idx, 1);<br>    });<br>  }<br>}<br><br>// somewhere in component<br>...<br>const isLoadingGetTodos = useIsLoading(ActionKey.GetAllTodos);<br>const isLoadingDeleteTodoFoo = useIsLoading(`${ActionKey.DeleteTodo}-Foo`);<br>const error = useError(ActionKey.GetAllTodos);<br>return (<br>  &lt;&gt;<br>    &lt;Button isLoading={isLoadingGetTodos} /&gt;<br>    &lt;Button isLoading={isLoadingDeleteTodoFoo} /&gt;<br>    &lt;Loading actionKey={ActionKey.GetAllTodos}&gt;I&#39;m replaced by spinner if needed &lt;/Loading&gt;<br>    &lt;ErrorMessageExemplaryComponent error={error} /&gt;<br>  &lt;/&gt;<br>);</pre><p>So the idea is that we can decorate any async MobX action we want to automatically set loading state and error in common store if needed. We don’t need any other manual work. Later we can easily consume them via useIsLoading / useError custom hooks and/or &lt;Loading /&gt; component.</p><h3>How to achieve it?</h3><p>Let’s create all those parts:</p><p>1. Common store:</p><pre>import { makeAutoObservable } from &#39;mobx&#39;;<br>import { HttpError } from &#39;types&#39;;<br>import { LoadingState } from &#39;./store.types&#39;;<br><br>class CommonStore {<br>  loadingStates: Record&lt;string, LoadingState&gt; = {};<br>  errors: Record&lt;string, HttpError&gt; = {};<br><br>  constructor() {<br>    makeAutoObservable(this, {}, { autoBind: true });<br>  }<br><br>  setLoadingState(actionKey: string, state: LoadingState) {<br>    this.loadingStates[actionKey] = state;<br>  }<br><br>  setError(actionKey: string, error: HttpError) {<br>    this.errors[actionKey] = error;<br>  }<br><br>  deleteError(actionKey: string) {<br>    delete this.errors[actionKey];<br>  }<br><br>  get allErrors() {<br>    return Object.values(this.errors);<br>  }<br>}<br><br>export default new CommonStore();</pre><p>2. Decorator:</p><pre>export type ActionKeyConfig = string | ((args: any) =&gt; string);<br><br>export function AutoLoadingState(actionKeyConfig: ActionKeyConfig) {<br>  return function (<br>    _target: object,<br>    key: string,<br>    descriptor: PropertyDescriptor<br>  ) {<br>    const originalFunction = descriptor.value;<br>    descriptor.value = async function (...args: any) {<br>      const actionKey =<br>        typeof actionKeyConfig !== &#39;string&#39;<br>          ? actionKeyConfig.apply(this, args)<br>          : actionKeyConfig;<br><br>      commonStore.setLoadingState(actionKey, &#39;loading&#39;);<br>      commonStore.deleteError(actionKey);<br>      try {<br>        await originalFunction.apply(this, args);<br>        commonStore.setLoadingState(actionKey, &#39;success&#39;);<br>      } catch (err) {<br>        commonStore.setLoadingState(actionKey, &#39;error&#39;);<br>        commonStore.setError(actionKey, err as HttpError);<br>      }<br>    };<br>  };<br>}</pre><p>3. Custom hooks:</p><pre><br>export const useIsLoading = (actionKey: string) =&gt; {<br>  const {<br>    common: { loadingStates },<br>  } = useStore();<br>  return loadingStates[actionKey] === &#39;loading&#39;;<br>};<br><br>export const useError = (actionKey: string) =&gt; {<br>  const {<br>    common: { errors },<br>  } = useStore();<br>  return errors[actionKey];<br>};</pre><p>4. &lt;Loading /&gt; component</p><pre>const Loading: FC&lt;LoadingProps&gt; = observer(({ actionKey, children }) =&gt;<br>  useIsLoading(actionKey) ? (<br>    &lt;Spinner /&gt;<br>  ) : (<br>    &lt;&gt;{children}&lt;/&gt;<br>  )<br>);</pre><p>Something important to mention is that it’s required to handle situations when loading state is related to particular item of a given action. Let’s consider such a feature:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*mcDzZWi6FouctpwSj2VHqw.gif" /></figure><p>Our key will be a combination of an action name and todo id (which is passed as an argument to the MobX action). That’s why our decorator supports passing not only a string but also a function that accepts the same parameters as the original method and allows you to compose action key dynamically based on that. For the same reason I decided to make an interface in common store flexible and I used string as a key instead of ActionKey:</p><pre>loadingStates: Record&lt;string, LoadingState&gt; = {};<br>errors: Record&lt;string, HttpError&gt; = {};</pre><p>Nevertheless, you can (and you should) use typed keys all over the places (decorator, custom hooks, Loading component) although TypeScript doesn’t force you to do so.</p><p>I perceive loading and error state management in frontend applications as a cross-cutting concern that spans across all the domains. That’s a good candidate to apply <a href="https://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect-Oriented Programming</a> techniques. Using the decorator to optionally opt-in to mechanism that is common for many different actions from different domain stores is exactly one of them. With a little effort on start, further development of async actions is going to be way more pleasant, consistent and reliable with this approach.</p><p>You can see the approach in action in this simple app: <a href="https://github.com/brojd/todo-app/tree/mobx-loading-states/frontend">https://github.com/brojd/todo-app/tree/mobx-loading-states/frontend</a></p><p>Live demo is here: <a href="https://todo-app-mobx-loading-states.onrender.com/">https://todo-app-mobx-loading-states.onrender.com/</a><br>Some notes though:<br>- it’s a free Render instance so backend spins down when there’s no traffic, that’s why you can encounter significant delay on loading first items<br>- delay in every backend response is done on purpose to easily present loading states</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6965ad738d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>