Skip to content

Autosuspend during dispatch #21

@objectliteral

Description

@objectliteral

Currently, when an action is dispatched, the action's return value is merged into the store one property at a time. This causes any callbacks to be executed for each property. It seems like React catches this for us by batching the individual setState calls successfully, so that rerenders occur only once per dispatch. But: 1) I don't want to rely completely on React to handle this well; this works for now, but ultimately I would like to deal with this issue inside of fleux. 2) The fact that React handles this well does not benefit any part of the application that is not a React component; if users were to add complex logic to their app that interacts with fleux and reimplements something like selectStateProps they would suffer from this issue. 3) While I don't generally expect selections to be expensive, it does seem unnecessary to run them multiple times for one and the same action.

Suggestions: Suspend callbacks from being invoked while the store is merged while tracking the updated properties and invoked callbacks only once per action after the merge is complete.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestperformancePerformance optimization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions