Events
For example when receiving an 'UserLoggedIn' event it is likely that you need to fetch some additional data. To facilitate this you can pass the user id in the event.Events are objects passed into the state machine with the intent of causing the FSM to transition to a new state.
You will often model real world events 'Turn Light on' but equally you will create many events that reflect internal events within your software or even somewhat abstract events that simply help your state machine to arrive in the correct state.
Some events won't result in a transition to a new state as the likes of a guard condition or a Join may not be satisfied.
To send an event to the state machine you use:
The call to 'applyEvent' is asynchronous however you MUST NEVER 'await' a call to 'applyEvent' as you risk deadlocking your state machine.
Event Data
You will often find it useful to pass information along with your event. You might have defined a sideEffect that uses data from your event.
Within your statemachine you can then define an sideEffect that takes that user id and fetches the user's credit score.
Terminology
Last updated