EventLifecycle
Defined in: event-lifecycle.ts:24
Lifecycle interface defines the methods for managing state transitions and effects. Implemented by StateMachine and StoreMachine to handle state changes. It provides a structured way to handle state changes, including guards, effects, and notifications.
Lifecycle steps:
transition(ev)
- Triggers the transition lifecycle, handling all steps for processing a change event.guard(ev)
- Checks if the transition is allowed.handle(ev)
- Processes the event, may abort if returns undefined.before(ev)
- Prepares for state change, may abort if returns undefined.update(ev)
- Applies the state update.effect(ev)
- Runs side effects, calls leave/enter hooks.leave(ev)
- Called when leaving the previous state.enter(ev)
- Called when entering the new state.notify(ev)
- Notifies subscribers of the change.after(ev)
- Final hook after transition completes.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
E |
Methods
Section titled “Methods”transition()
Section titled “transition()”transition(
change
:E
):void
Defined in: event-lifecycle.ts:28
Triggers the transition lifecycle, handling all steps for processing a change event.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
change | E |
Returns
Section titled “Returns”void
guard()
Section titled “guard()”guard(
ev
:E
):boolean
Defined in: event-lifecycle.ts:32
Checks if a transition event is allowed to proceed. Returns true to continue, false to abort.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”boolean
handle()
Section titled “handle()”handle(
ev
:E
):undefined
|E
Defined in: event-lifecycle.ts:36
Processes the event. May abort the transition if returns undefined.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”undefined
| E
before()
Section titled “before()”before(
ev
:E
):undefined
|E
Defined in: event-lifecycle.ts:41
Called before the transition is applied. May abort if returns undefined. (Represents a beforeTransition hook, not state entry/exit.)
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”undefined
| E
update()
Section titled “update()”update(
ev
:E
):void
Defined in: event-lifecycle.ts:45
Applies the state update.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”void
effect()
Section titled “effect()”effect(
ev
:E
):void
Defined in: event-lifecycle.ts:49
Runs side effects for the transition. By default, calls leave
and enter
hooks.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”void
leave()
Section titled “leave()”leave(
ev
:E
):void
Defined in: event-lifecycle.ts:53
Called when leaving the previous state.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”void
enter()
Section titled “enter()”enter(
ev
:E
):void
Defined in: event-lifecycle.ts:57
Called when entering the new state.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”void
notify()
Section titled “notify()”notify(
ev
:E
):void
Defined in: event-lifecycle.ts:61
Notifies subscribers of the change.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”void
after()
Section titled “after()”after(
ev
:E
):void
Defined in: event-lifecycle.ts:65
Final hook after transition completes. (Represents afterTransition, not state entry/exit.)
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ev | E |
Returns
Section titled “Returns”void