The way I think of it, is that you should not pass absolute values in Msg
s. A Msg
should always pass a delta value (or no value at all if it is just a trigger or state change on the model, as noted in your article).
In your calendar example, instead of:
type Msg
= SetOffset Int
You can do:
type Msg
= SetDelta Int
Where the delta is -1, 0, 1 for PreviousDay, CurrentDay or NextDay, or some other value for a bigger change. Of course these are the same thing, just named differently, but its how you treat the value that matters:
type Msg
= SetOffset Int
| ...
update model msg =
case msg of
SetOffset val -> { model | offset = val }
...
Versus this way, where the value is applied as a delta to the model:
type Msg
= SetDelta Int
| ...
update model msg =
case msg of
SetDelta val -> { model | offset = model.offset + val }
...
I made this Ellie to illustrate the effect of stale data from the view
: https://ellie-app.com/yVC9wPk33xa1