Creating Async Middleware #1472
Replies: 2 comments 5 replies
-
React will provide first-class promise support in the future. It would help dealing with async. Not a current solution though. |
Beta Was this translation helpful? Give feedback.
2 replies
-
The loading middleware is to set isLoading status for every action which has http request. We may have several data requests in one page, we can group all of them to a namespace, if any of the request is pending we show the Loader. Hide it when all of them are completed. Do you have any idea to accomplish it in zustand ?
Can this be done in v5?
v5 isn't different from v4 in this sense.
I need to create a global loading middleware.
Interesting idea. How does it look like?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am planning to create an async middleware.
Consider this example,
I wish to keep
loading
as true, when fetch call is happening. Once it is done it will be reverted back to false. I'll be using thisloading
property in a loader component. Since I currently have around 20 similar fetch calls which will drastically increase, I am planning to take this approach. Kindly suggest if there are other better approaches too.I want the logs to in the order 1,2,3,4,5. Currently it get executed in 1,2,3,5,4 Order as middleware doesn't wait for statement marked as (1) to be completed.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions