Seeing Commands in the time traveling debugger

Hello, I’m very new to Elm and have to say that I really like the time traveling debugger :slight_smile:

Since my Browser.element app is controlled by the following function:

update : Msg -> Model -> ( Model, Cmd Msg )

I’d love to also see the commands in the time traveling debugger. Is that currently possible? If not how difficult would it be to implement this?

1 Like

Guess it would be hard. Cmd are quite opaque.

What is the problem? Perhaps there is some other way to solve it.

I can see the Msg in the debugger so I can then conclude the Cmd from that. Is that not enough?

It requires some code changes, but the Effect pattern (The effects pattern - Elm Patterns) allows logging the effects that are returned. It is a fairly invasive change, but it can be a boon for testing as well, and is a prerequisite for elm-program-test (elm-program-test 3.5.0)

I would have guessed the opposite: That adding this feature to the debugger would be easier since Cmd are opaque.

You can use if-else in update so you can never tell for sure which commands are sent.

This is a very interesting question! I’ve never thought about it before, but it does sound useful to see not just see the resulting model after each message, but also the resulting commands! I’ve added Debug.log at commands before to see if they get triggered or not, so just getting that directly from the debugger does sound time saving. Similarly, it might be useful to see which subscriptions we have after each message, too!

It would guess this requires going through the Kernel (JS) code for all elm/* packages and attach some kind of debugging information to the commands that they can produce, and probably only when the debugger is enabled (the compiler has support for switching between different JS code for dev/prod using comments).

Then one would need to update the browser/src/Debugger at master · elm/browser · GitHub code to display commands (and subscriptions), as needed (for example, not for Browser.sandbox).

I have dug around a bit in the Debugger source code before, so it does sound possible but it’d take an answer from someone who has actually worked on it to get a more precise answer.

3 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.