I wonder if a better example would have been to model the actions from a calculator.
commands = [
%{action: "press button", value: 1},
%{action: "press button", value: :plus},
%{action: "press button", value: 1},
%{action: "press button", value: :equal},
]
When you run through these commands, the event handler for a button press with the value of equal would attempt to run the calculation. All other events would build a buffer.
This isn’t perfect either though since you’d need to introduce taking input into the example with complicates things in addition to holding state.