-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging lift
operations ?
#1
Comments
We could wrap every reducer in Logger Reducer which would be something like this:
Written without compiler, it may need some adjustments. |
If you make this a func generic over ActionType and StateType, then you can wrap it before lifting, which will be great because will discard any action that the inner reducer doesn't actually handle. |
I agree that having side-effects on the Reducer isn't ideal. The wrapper would be a good start. I was also looking at potentially adding logging inside the Reducer's |
The wrapper can easily become an extension such as: Reducer<NavigationAction, AppState>
.navigation
.logging("Navigation")
.lift(action: \AppAction.navigation) Adding to the "reduce" function makes it baked into your app logic and hard to reuse, imo. extension Reducer {
func logging(_ name: String) -> Reducer {
Reducer { action, state in
print("Reducing \(action) on \(name)")
self.reduce(action, &state)
}
}
} |
@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 🤨.
Initially I was seeing the appropriate actions being triggered :
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 :
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
was indeed being triggered, it was going nowhere.
The text was updated successfully, but these errors were encountered: