@@ -306,33 +306,29 @@ private extension StoreContext {
306
306
updatedScopes [ currentScope. key] = currentScope
307
307
}
308
308
309
- // Performs update of the given atom with the dependency's context.
310
- func performUpdate( for key: AtomKey , cache: some AtomCacheProtocol , dependency: some Atom ) {
311
- dependency. producer. performUpdate {
312
- // Dependents must be updated with the scope at which they were initialised.
313
- let localContext = StoreContext (
314
- store: store,
315
- rootScope: rootScope,
316
- currentScope: cache. initializedScope
317
- )
318
-
319
- let didUpdate = localContext. transitiveUpdate ( for: key, cache: cache)
320
-
321
- guard didUpdate else {
322
- // Record the atom to avoid downstream from being update.
323
- skippedDependencies. insert ( key)
324
- return
325
- }
309
+ func transitiveUpdate( for key: AtomKey , cache: some AtomCacheProtocol ) {
310
+ // Dependents must be updated with the scope at which they were initialised.
311
+ let localContext = StoreContext (
312
+ store: store,
313
+ rootScope: rootScope,
314
+ currentScope: cache. initializedScope
315
+ )
326
316
327
- if let scope = cache. initializedScope {
328
- updatedScopes [ scope. key] = scope
329
- }
317
+ let didUpdate = localContext. transitiveUpdate ( for: key, cache: cache)
318
+
319
+ guard didUpdate else {
320
+ // Record the atom to avoid downstream from being update.
321
+ skippedDependencies. insert ( key)
322
+ return
323
+ }
324
+
325
+ if let scope = cache. initializedScope {
326
+ updatedScopes [ scope. key] = scope
330
327
}
331
328
}
332
329
333
- // Performs update of the given subscription with the dependency's context.
334
- func performUpdate( subscription: Subscription , dependency: some Atom ) {
335
- dependency. producer. performUpdate ( subscription. update)
330
+ func performUpdate( dependency: some Atom , body: @MainActor ( ) -> Void ) {
331
+ dependency. producer. performUpdate ( body)
336
332
}
337
333
338
334
func validEdge( _ edge: Edge ) -> Edge ? {
@@ -365,7 +361,9 @@ private extension StoreContext {
365
361
let dependencyCache = store. state. caches [ edge. from]
366
362
367
363
if let cache, let dependencyCache {
368
- performUpdate ( for: key, cache: cache, dependency: dependencyCache. atom)
364
+ performUpdate ( dependency: dependencyCache. atom) {
365
+ transitiveUpdate ( for: key, cache: cache)
366
+ }
369
367
}
370
368
371
369
case . subscriber( let key) :
@@ -377,7 +375,7 @@ private extension StoreContext {
377
375
let dependencyCache = store. state. caches [ edge. from]
378
376
379
377
if let subscription, let dependencyCache {
380
- performUpdate ( subscription : subscription , dependency : dependencyCache . atom )
378
+ performUpdate ( dependency : dependencyCache . atom , body : subscription . update )
381
379
}
382
380
}
383
381
}
0 commit comments