Accessing the event that led to the current state


#1

There are often several events that can lead to a state transition into any given state. I need to know the event that led to the current state, to simulate the correct behavior.

Is there any way to access the triggering event?


#2

Hi @pjkundert, thanks for writing.

Unfortunately, Sketch.systems doesn’t expose the underlying event behind a state transition.
Having access to that event can be helpful in a programmatic context (i.e., a full implementation), but that’s not our focus w/ Sketch.systems.
We’re trying to keep the tool about a high-level “sketch” rather than a complex IDE where one can write arbitrary code to drive the system behavior.

Can you say more about the system behavior you are trying to describe?
Have you tried capturing the behavior with the transient state convention?

Personally, I find it helpful to design the system so that the states capture as much information as possible — would it make sense in your situation to actually break things out into multiple states, rather than trying to have code embedded within a single state that “makes a decision”?