Skip to content

Commit a9c3fec

Browse files
authored
Add delay to child dismissal (#3796)
By immediately `nil`-ing out the child store, SwiftUI can misbehave in a number of ways. This PR attempts to fix #3789, #3783, #3779.
1 parent 9424b18 commit a9c3fec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/ComposableArchitecture/Store.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ public final class Store<State, Action>: _Store {
343343
.sink { [weak self, weak parent] _ in
344344
guard let scopeID = self?.scopeID
345345
else { return }
346-
parent?.removeChild(scopeID: scopeID)
346+
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300)) {
347+
parent?.removeChild(scopeID: scopeID)
348+
}
347349
} receiveValue: { [weak self] _ in
348350
guard let self else { return }
349351
self._$observationRegistrar.withMutation(of: self, keyPath: \.currentState) {}

0 commit comments

Comments
 (0)