in src/StoreBase.ts [202:250]
private static _resolveCallbacks(): void {
// Prevent a store from triggering while it's already in a trigger state
if (StoreBase._isTriggering) {
StoreBase._triggerPending = true;
return;
}
StoreBase._isTriggering = true;
StoreBase._triggerPending = false;
if (Instrumentation.impl) { Instrumentation.impl.beginInvokeStoreCallbacks(); }
let callbacksCount = 0;
const currentTime = Date.now();
// Capture the callbacks we need to call
const callbacks: [SubscriptionCallbackFunction, string[]|undefined][] = [];
for (const [callback, meta] of this._pendingCallbacks){
// Block check
if (StoreBase._triggerBlockCount > 0 && !meta.bypassBlock) {
continue;
}
// Throttle check
if (meta.throttledUntil && meta.throttledUntil > currentTime && !StoreBase._bypassThrottle) {
continue;
}
// Do a quick dedupe on keys
const uniquedKeys = meta.keys ? uniq(meta.keys) : meta.keys;
// Convert null key (meaning "all") to undefined for the callback.
callbacks.push([callback, uniquedKeys || undefined]);
this._pendingCallbacks.delete(callback);
}
for (const [callback, keys ] of callbacks) {
callbacksCount++;
callback(keys);
}
if (Instrumentation.impl) { Instrumentation.impl.endInvokeStoreCallbacks(this.constructor, callbacksCount); }
StoreBase._isTriggering = false;
if (this._triggerPending) {
StoreBase._resolveCallbacks();
}
}