Skip to content

Commit c058a10

Browse files
committed
Fix strong token capture in observe(_:onChange:task)
1 parent 5df4eb9 commit c058a10

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/SwiftNavigation/Observe.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ func observe(
247247
) -> ObserveToken {
248248
let token = ObserveToken()
249249
SwiftNavigation.onChange(
250-
of: tracking,
250+
of: { [weak token] transaction in
251+
guard let token, !token.isCancelled else { return }
252+
tracking(transaction)
253+
},
251254
perform: { [weak token] transaction in
252255
guard
253256
let token,

0 commit comments

Comments
 (0)