T
TanStack3y ago
generous-apricot

How to get global access to all mutations that are running?

I am making an app where offline support is critical. I have managed to get mutations to work for offline usage. One thing that I am missing is the ability to see the status of each mutation. to see if it fails, succeeds or is still loading. There will be a component where you are able to see all of requests and their respective status. Any tips for how to getting access to the data?
2 Replies
correct-apricot
correct-apricot3y ago
To me that’s just UI state data. I would create a “store” that keeps track of the mutation states. The mutations update their state in the store and subscribers to those changes can update their UI appropriately. useSyncExternalStore is handy here. This is all assuming I’m not using a state library like Zustand etc.
unwilling-turquoise
unwilling-turquoise3y ago

Did you find this page helpful?