Add deferSubscriberNotifications Function that defers subscribers (and observables) notification until the end of some action. This is necessary when running a flow that creates intermediate states we don't want to react to.
To handle the conflict between deferSubscriberNotifications and flush, add optional config to the flush function:
excecutionType: default- meaning flush would happen right after we stop deferring notifications. Flush when not deferring notifications stays the same.
excecutionType: scheduled- meaning flush would notify all without canceling render and requesting animation frame, regardless if notifications are currently being deferred.
excecutionType: immediate - meaning flush would happen immediately regardless if notifications are currently being deferred.
In general, the deferSubscriberNotifications solution is:
deferSubscriberNotifications receives some action we would like to perform while deferring notifications.
If notifications are already deferred, run action without doing anything else (to support nesting deferSubscriberNotifications)
Set deferNotifications flag to true before running the action
When calling notifyAll while deferNotifications is set to true, return without notifying
Finally, set deferNotifications back to false, and flush\notify if someone tried to flush (not immediate) or notify while deferring notifications.
Add
deferSubscriberNotifications
Function that defers subscribers (and observables) notification until the end of some action. This is necessary when running a flow that creates intermediate states we don't want to react to.To handle the conflict between
deferSubscriberNotifications
andflush
, add optional config to the flush function:excecutionType: default
- meaning flush would happen right after we stop deferring notifications. Flush when not deferring notifications stays the same.excecutionType: scheduled
- meaning flush would notify all without canceling render and requesting animation frame, regardless if notifications are currently being deferred.excecutionType: immediate
- meaning flush would happen immediately regardless if notifications are currently being deferred.In general, the
deferSubscriberNotifications
solution is:deferSubscriberNotifications
receives some action we would like to perform while deferring notifications.deferSubscriberNotifications
)deferNotifications
flag to true before running the actionnotifyAll
whiledeferNotifications
is set to true, return without notifyingdeferNotifications
back to false, and flush\notify if someone tried to flush (not immediate) or notify while deferring notifications.