Defining Initial Status
Each Retomus machine starts in an initial status, which you can define as a fixed string or a function that dynamically determines the starting point.
๐ง Static Initial Statusโ
The simplest form is a string value:
initialStatus: {
  status: 'idle',
  options: { staticSetup: true },
}
๐ค Dynamic Initial Statusโ
Use a function to determine the starting status based on context:
initialStatus: {
  status: (ctx) => {
    return ctx.state.count > 0 ? 'incrementing' : 'idle';
  },
  options: { dynamicSetup: true },
}
This is useful for restoring persisted state or initializing based on runtime conditions.
๐งช Available Optionsโ
| Option | Description | 
|---|---|
staticSetup | Use a static string (default) | 
dynamicSetup | Evaluate function at runtime | 
You can combine both:
initialStatus: {
  status: (ctx) => 'idle',
  options: {
    staticSetup: true,
    dynamicSetup: true,
  },
}
โ ๏ธ Gotchasโ
- If both 
staticSetupanddynamicSetuparetrue, dynamic logic takes precedence - Always return a valid status from dynamic functions
 
๐ Config Placementโ
initialStatus is passed as part of your machine config:
createMachineConfig({
  ...
  initialStatus: { ... }
});