-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(store): reduce change detection cycles with pending tasks
An `INFINITE_CHANGE_DETECTION` error has been logged to the error service multiple times, occurring randomly depending on the number of actions dispatched in a row. This happens because a pending task is added every time an action is dispatched. Removing a pending task via the public API forces a scheduled tick, ensuring that stability is asynchronous and delayed until there has been at least an opportunity to run app synchronization. This change reduces the number of change detection cycles. For example, if 10 synchronous actions are dispatched in a row, it may previously trigger 10 change detection cycles, as tasks would be removed 10 times. We listen to the actions stream, and every time a context with a `dispatched` status is generated, we add a pending task only once and keep it until the action is completed. If multiple actions are dispatched at the same time, we debounce them and use `buffer` to collect them into a single list.
- Loading branch information
Showing
3 changed files
with
55 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters