I'm quite new to Elmish. Did a sample template using dotnet new SAFE
. When I open the app and use redux dev tools Chrome extension I always get message which is "UserMsg". Is there a way to make it "Increment" or "Decrement" when I click the button "-" or "+"?
Asked
Active
Viewed 42 times
0

user1325696
- 616
- 1
- 8
- 16
1 Answers
0
The elmish-browser Navigation module wrap all messages in the Parser type which is a union of either Change (for a URL change) or UserMsg (for everything else).
This breaks the reflection in both withDebugger and withConsoleTrace... they are unable to grab the name of the underlying message, and hence display the wrapped name instead.
The work-around is to invoke toNavigable after withDebugger in the program initialization pipeline:
Program.mkProgram init update view
#if DEBUG
|> Program.withConsoleTrace
#endif
|> Program.withReactBatched "elmish-app"
#if DEBUG
|> Program.withDebugger
#endif
|> Program.toNavigable (parseHash route) urlUpdate
|> Program.run
However, by doing this the "Change" messages are no longer sent to the debugger. This could be a problem if your urlUpdate function is updating the model state directly. It may be better for your urlUpdate function to raise a new command with a message to be handled by the main update function.

nakedfanatic
- 3,108
- 2
- 28
- 33