Skip to main content

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 vs doToggleNow)
  • 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,
};