Open Kondamon opened 1 year ago
Hello, @Kondamon!
I'm facing with the exact same issue, after EnvironmentObject
updates whenever I try to route to other screen app crashes. Did you find a solution to this problem?
@onl1ner, I didn‘t resolve the issue. Used another framework.
Oh, I see, @rundfunk47 could you please help with this issue?
I would recommend against using RouterStore. It will probably be removed in the next version. Instead, I'd recommend you to use whatever dependency injection framework or method you already use throughout your app and put the coordinators there.
Stinsen is not a dependency injection framework and RouterStore comes pretty close to that.
With that being said, I should give it a look 👀
A StateObject
should not live at the App
level, it will trigger a redraw of the view for new changes and is just generally inadvisable. This is probably throwing the RouterStore
into a weird state.
Facing the same issue when trying to implement background scene phase
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
MainCoordinator()
.view()
.onChange(of: scenePhase) { currentPhase in
guard currentPhase == .background else {
return
}
print("App run in background")
}
}
}
Is this issue still doesn't have a solution?
We have implemented
StateObject
into an app, as shown in the example below and we receive a lot of issues with the Coordinator such as crashes. The problems start to arise as soon as the StateObject is changed (due to updates). During debugging I have found out that the RouterStore holds a lot of Coordinators twice or three times and I guess this is the reason for the issues. However, I was not able to yet to create a minimal example for easier debugging of this issue.