Defining Actions
In Retomus, actions are named events that trigger transitions between statuses.
They can optionally carry a payload and invoke logic via an action handler.
๐ What is an Action?โ
An action is a string identifier for an event your machine can respond to.
const actions = ['increment', 'decrement', 'reset'];
Each action maps to:
- A transition (status change)
- A handler (side effect logic)
- Optional payload
๐งช Good Practices for Action Namingโ
- Use verbs (
increment
,fetch
,submit
) - Be declarative, not imperative (
toggle
vsdoToggleNow
) - Use snake_case or camelCase consistently
๐ก Tip: Keep action names flatโ
// โ
Good
const actions = ['start', 'stop', 'reset'];
// โ Bad (deep nesting not supported)
const actions = {
start: true,
stop: true,
};