Creating a Machine
Once you've defined your machine config, use retomus.createMachine()
to generate a running instance of the machine.
π οΈ Basic Usageβ
const counterMachine = retomus.createMachine(machineConfig);
This returns a stateful instance with hooks and APIs like:
.useState()
.useAction()
.useStatus()
.setup()
π― Unique ID Requirementβ
Each machine must have a unique id
:
const machineConfig = {
id: 'myMachine',
...
};
Reusing the same id
for multiple machines will result in unexpected behavior.
π‘ Register Earlyβ
Itβs common to register machines at app startup, especially if they are global or shared across components.