-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Priority for action dispatches #1680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you clarify what you mean by "bubble to root", and "order actions"? Redux only dispatches a single action at a time. You can technically do another dispatch in the store's subscription callback, but that has to be done conditionally or else you wind up with an infinite loop. It might also help if you can describe your use case further. |
Does this help? #1676 (comment) |
I will try to provide a detailed view: |
I'm afraid this is generally an anti pattern that we don't recommend. Can you tell more about your use case? Why did you need this? |
The basic functionality i need is data fetching on state initialization. No matter what route the app is in, it should populate the initial state with data from a certain API. There are cases when the data is page specific, and some where its global to the whole app, like user data on authentication, dynamic sidebar content. this generally sits in the root component and is used by multiple child components. The further expand on the problem i was face'ing, during the initial request, I would normally have a indicators in the state that would tell me if the global data is loaded or needs to be refreshed. This loads of a subscriber. Since the action was a thunk, the initial load, would dispatch a couple of actions one after a another. This would overlap. Firing one action from the subscriber, and one from the components lifecycle ComponentWillMount, this returns a error, since the state does not contain the desired data yet. One other option i could think of was rerendering when the props are present. |
Hello, have been working with redux for quite a while now. Can honestly say loving it. One thing I noticed that by working with bigger applications that have multiple actions being dispatched via thunks, they always bubble to root. Is there a way to control this without altering the structure? There are some cases, when you want to order Action calls, or force that no other child invoked actions would be called before the current finishes? If its a architecture or a implementation problem, would greatly appreciate some pointers on how to deal with this.
Thanks!
The text was updated successfully, but these errors were encountered: