I’m trying to figure out what kind of logic should run during
view and what should run during
Suppose I have a button whose operation depends on the current context. (e.g. the first time you press it it triggers a SaveValue, and following it’ll trigger an UpdateValue).
There are 2 ways I can do this:
viewtrigger a generic
ButtonClickedmessage, and sort out the operation based on the model during
- do the work to sort out the operation based on the model during
view, and have the button trigger the specific message.
The immediate intuition may be that the first is better. That is, do your real work/logic in
update. But, consider functions like
stopPropagationOn. They require us to make this sort of “model -> behaviour” calculation in
The only other option is to calculate
update, and use that pre-computed value during
view, but this goes against the idea of storing derivable values.
I’m left to conclude, that it is most consistent (and correct), for
view to determine the exact nature of the message to be dispatched. So we should never see messages like
KeyPressed Int or
ButtonPressed, but rather
SaveValue (for example).