-
Notifications
You must be signed in to change notification settings - Fork 1
Description
@luizmb, I am finally getting to look at the log output from the LoggerMiddleware. It's pretty awesome so far !
Issue
I was debugging a state change for a modal sheet that was supposed to be presented when a button / icon was pressed.. but was not 🤨.
...
var body: some View {
NavigationView {
List {
...
}
.navigationBarItems(trailing: profileButton)
.sheet(isPresented: viewModel.binding[\.isShowingUserProfile]) { Text("User Profile") }
}
}
var profileButton: some View {
Button(action: { viewModel.dispatch(.showUserProfile) }) {
Image(systemName: viewModel.state.iconName)
.imageScale(.large)
.accessibility(
label: Text(viewModel.state.iconAccessibilityLabel.localizedCapitalized)
)
.padding()
}
}
Initially I was seeing the appropriate actions being triggered :
2020-08-27 15:07:11.374696-0500 App[7300:453348]
🕹 navigation(App.NavigationAction.showUserProfile)
🎪 Home.swift:34 profileButton
However AppState was never changing. Took me 5 min (!) to figure out that the Reducer for that Navigation part had never been added to the global Reducer.app to lift the NavigationAction :
extension Reducer where ActionType == AppAction, StateType == AppState {
static let app =
<reducer1>
<>
<reducer2>
<>
<reducer3>
---- missing --->
<> Reducer<NavigationAction, AppState>.navigation.lift(
action: \AppAction.navigation
---- missing ---<
) <> Reducer<AppLifecycleAction, AppLifecycle>.lifecycle.lift(
action: \AppAction.appLifecycle,
state: \AppState.appLifecycle
)
}
Once this was added, things worked great. However the trace output was no different than what I had before (except for the State that had not changed).
Request
Would it be possible to have a trace that highlights the "part" reducers getting lifted all the way up to the top Reducer (i.e. seeing the chain) so that, in my case for example, I would have seen that while the
🕹 navigation(App.NavigationAction.showUserProfile)
was indeed being triggered, it was going nowhere.