I’d like to clarify my understanding on why views cannot produce side-effects directly.
Here is an example where I have a simple view with a button. When the user clicks the button I’d like to produce a random value (a side-effect), but in order to do so I need to produce a
Cmd Msg which can only be done from the
update function. So another distinct
Msg is needed to tell the update function to produce the Cmd.
I understand why this is strictly from a function annotation perspective. You need a
Cmd to produce a side-effect. Randomness (with
Random.generate) is a side-effect and the view function’s annotation doesn’t work with Cmds.
I can’t say I understand it from a TEA perspective yet and that I’m missing something obvious. Shouldn’t event handlers in the view be able to produce side-effects directly?