diff --git a/src/appHost.tsx b/src/appHost.tsx index 2550e5f..0f30ca1 100644 --- a/src/appHost.tsx +++ b/src/appHost.tsx @@ -129,7 +129,7 @@ export function createAppHost(initialEntryPointsOrPackages: EntryPointOrPackage[ let isInstallingEntryPoints: boolean = false let isStoreSubscribersNotifyInProgress = false let isObserversNotifyInProgress = false - let isDeferringNotifications = false + let shouldFlushMemoizationSync = false const entryPointsInstallationEndCallbacks: Map void> = new Map() verifyLayersUniqueness(options.layers) @@ -667,8 +667,8 @@ miss: ${memoizedWithMissHit.miss} notifyObserversIsRunning => { isObserversNotifyInProgress = notifyObserversIsRunning }, - deferNotifications => { - isDeferringNotifications = deferNotifications + updateShouldFlushMemoizationSync => { + shouldFlushMemoizationSync = updateShouldFlushMemoizationSync } ) store.subscribe(() => { @@ -679,7 +679,7 @@ miss: ${memoizedWithMissHit.miss} }) store.syncSubscribe(() => { shouldFlushMemoization = true - if (isStoreSubscribersNotifyInProgress || isObserversNotifyInProgress || isDeferringNotifications) { + if (isStoreSubscribersNotifyInProgress || isObserversNotifyInProgress || shouldFlushMemoizationSync) { shouldFlushMemoization = false flushMemoizedForState() } diff --git a/src/throttledStore.tsx b/src/throttledStore.tsx index bb71701..147aec7 100644 --- a/src/throttledStore.tsx +++ b/src/throttledStore.tsx @@ -158,7 +158,7 @@ export const createThrottledStore = ( cancelAnimationFrame: Window['cancelAnimationFrame'], updateIsSubscriptionNotifyInProgress: (isSubscriptionNotifyInProgress: boolean) => void, updateIsObserversNotifyInProgress: (isObserversNotifyInProgress: boolean) => void, - updateIsDeferringNotifications: (isDeferringNotifications: boolean) => void + updateShouldFlushMemoizationSync: (shouldFlushMemoizationSync: boolean) => void ): PrivateThrottledStore => { let pendingBroadcastNotification = false let pendingObservableNotifications: Set | undefined @@ -287,12 +287,12 @@ export const createThrottledStore = ( try { executePendingActions() isDeferrringNotifications = true - shouldClearMemoizedForState && updateIsDeferringNotifications(isDeferrringNotifications) + shouldClearMemoizedForState && updateShouldFlushMemoizationSync(isDeferrringNotifications) const functionResult = await action() return functionResult } finally { isDeferrringNotifications = false - shouldClearMemoizedForState && updateIsDeferringNotifications(isDeferrringNotifications) + shouldClearMemoizedForState && updateShouldFlushMemoizationSync(isDeferrringNotifications) executePendingActions() } }