which trips the observation in the maincoordinator:
@ViewBuilder func sharedView(_ view: AnyView) -> some View {
view
.onReceive(AuthenticationService.shared.$status, perform: { status in
switch status {
case .unauthenticated:
self.root(\.unauthenticated)
case .authenticated(let user):
self.root(\.authenticated, user)
}
})
}
However, on switching the root, the AuthenticatedCoordinator does not deinit and neither do any of its children.
Furthermore, it appears as if Stinsen attempts to redraw the TabCoordinatable as the root is switched. This causes odd behavior like task and onAppear closures being called on the views that were brought into the view hierarchy. To reproduce do the following:
Add a task like so to the TodosScreen
@ViewBuilder var content: some View {
ScrollView {
#if !os(iOS)
button
#endif
if todosStore.all.isEmpty {
InfoText("You have no stored todos.")
}
VStack {
ForEach(todosStore.all) { todo in
Button(todo.name, action: {
todosRouter.route(to: \.todo, todo.id)
})
}
}
.padding(18)
}
.navigationTitle(with: "Todos")
.task {
print("here at the wall")
}
}
Launch the app
Tap "Login" and then navigate to the Todos tab. Note: you will see here at the wall printed in Xcode console.
Navigate to the profile tab and tap "logout"
Observe: "here at the wall" is printed again after the root has been switched to unauthenticated
This behavior can be observed in the example app. The logout button on the profile screen calls:
which trips the observation in the maincoordinator:
However, on switching the root, the AuthenticatedCoordinator does not deinit and neither do any of its children.
Furthermore, it appears as if Stinsen attempts to redraw the TabCoordinatable as the root is switched. This causes odd behavior like
task
andonAppear
closures being called on the views that were brought into the view hierarchy. To reproduce do the following:Add a
task
like so to the TodosScreenLaunch the app
Tap "Login" and then navigate to the Todos tab. Note: you will see
here at the wall
printed in Xcode console.Navigate to the profile tab and tap "logout"
Observe: "here at the wall" is printed again after the root has been switched to
unauthenticated