You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, reflux setState does not support a callback. I believe expected functionality here would be that it worked like or better than the typical React setState.
Suggestion:
Set expected completions based on number of subscribed components.
While looping setState for all subscribed components, fire off a callback on that component's setState indicating it is complete.
When all completions are reached, fire the callback for the reflux store's setState.
I believe this could also be wrapped as a promise instead of a callback. Honestly, I'm not sure why the normal React setState is a callback and not a promise.
The text was updated successfully, but these errors were encountered:
Reflux's this.setState does not have a callback because it changes its store state immediately. React only has callbacks as a workaround for the fact that it doesn't. It would be very awkward (and even confusing) to implement a workaround that "works around" a problem that doesn't actually exist in Reflux.
As for your suggestion that it instead call back when all subscribing components have updated their state: that is a major violation of the single most fundamental principle of flux itself (one-way data flow).
If your store logic depends upon knowing the state of subscribed components then you're doing something very different from flux!
However, I definitely see that this should be documented so that people know they don't need callbacks, and will get that in the docs soon.
Currently, reflux setState does not support a callback. I believe expected functionality here would be that it worked like or better than the typical React setState.
Suggestion:
Set expected completions based on number of subscribed components.
While looping setState for all subscribed components, fire off a callback on that component's setState indicating it is complete.
When all completions are reached, fire the callback for the reflux store's setState.
I believe this could also be wrapped as a promise instead of a callback. Honestly, I'm not sure why the normal React setState is a callback and not a promise.
The text was updated successfully, but these errors were encountered: