machine
machine
Generic state machine system built on XState with built-in activities and services for UI layouts.
@quicksave/machine
Namespaces
Classes
Interfaces
Type Aliases
Event
Ƭ Event: xstate.EventObject
Sender
Ƭ Sender<EventT
>: xstate.Sender
<EventT
>
Type parameters
Name | Type |
---|---|
EventT |
extends Event |
State
Ƭ State: xstate.StateSchema
<Context
> & { states
: { [key: string]
: State
; } }
Functions
activity
▸ activity<ContextT
, EventT
>(activity
): (context
: ContextT
) => (sendBack
: Sender
<EventT
>) => () => void
Helper to convert an activity function with context
and sendBack
parameters to an xstate
compatible callback service declaration.
For example an xstate service like this:
function foobar(context) {
return (sendBack) => {
// ...
};
}
Can be simplified into this by wrapping the service assignment with activity(foobar)
:
function foobar(context, sendBack) {
// ...
}
Type parameters
Name | Type |
---|---|
ContextT |
extends Context |
EventT |
extends EventObject |
Parameters
Name | Type | Description |
---|---|---|
activity |
(context : ContextT , sendBack : Sender <EventT >) => () => void |
The activity function to convert |
Returns
fn
▸ (context
): (sendBack
: Sender
<EventT
>) => () => void
Parameters
Name | Type |
---|---|
context |
ContextT |
Returns
fn
▸ (sendBack
): () => void
Parameters
Name | Type |
---|---|
sendBack |
Sender <EventT > |
Returns
fn
▸ (): void
Returns
void