-
-
Notifications
You must be signed in to change notification settings - Fork 60
Description
I’m seeing stale states sometimes in connected views. Can’t figure it out — have removed all middleware. It looks like after an action is processed and the state is updated, map(state:dispatch:) is called with the old state. But only sometimes (perhaps 20% of the time).
func map(state: AppState, dispatch: @escaping DispatchFunction) -> Props {
print("Latest screen:", state.diaryState.currentScreen) // Sometimes currentScreen doesn't updateI would happily dig into this or submit a PR but I’m stumped. The Store implementation looks straightforward. I can’t produce a reduced test case but at the same time there’s nothing unusual about the project I’m seeing the issue in.
Adding in an additional DispatchQueue.main.async {} into a new middleware fixes it most of the time but not always. I guess it has to be something to do with how SwiftUI is coalescing updates to the @Published public var state: StoreState store property.