Built-in Actions

Every action Milo dispatches automatically.

2 min read 447 words

Milo dispatches these actions automatically during the application lifecycle. Your reducers can handle any of them.

Action reference

Action Trigger Payload Description
@@INIT Store creation Dispatched once when the store is created. Use this to set initial state.
@@KEY Keyboard input Key(char, name, ctrl, alt, shift) Dispatched for every keypress. The payload is a frozenKeydataclass.
@@TICK Timer interval Dispatched at the configuredtick_rateinterval. Use for animations, polling, or periodic updates.
@@RESIZE Terminal resize (cols, rows) Dispatched when the terminal window is resized (viaSIGWINCH).
@@NAVIGATE Screen transition screen_name Dispatched by the flow system to move between screens.
@@HOT_RELOAD Template file change file_path Dispatched byDevServerwhen a watched template file changes.
@@EFFECT_RESULT Saga completion result Dispatched when a saga'sCalleffect completes.
@@QUIT Ctrl+C Dispatched when the user presses Ctrl+C. The app exits after processing this action.
@@SAGA_ERROR Saga exception {error, type} Dispatched when an unhandled exception occurs in a saga. Payload includes the error message and exception type name.
@@CMD_ERROR Cmd exception {error, type} Dispatched when an unhandled exception occurs in aCmd thunk. Same payload shape as @@SAGA_ERROR.
@@PIPELINE_START Pipeline begins pipeline_name Dispatched when aPipelinestarts execution.
@@PIPELINE_COMPLETE Pipeline finishes pipeline_name Dispatched when aPipelinecompletes all phases.
@@PHASE_START Phase begins phase_name Dispatched when a pipeline phase starts.
@@PHASE_COMPLETE Phase finishes phase_name Dispatched when a pipeline phase completes successfully.
@@PHASE_FAILED Phase fails phase_name Dispatched when a pipeline phase fails.

Tip

All built-in action types are prefixed with@@ to avoid collisions with your custom actions. You can access them programmatically via the BUILTIN_ACTIONSconstant.

Custom actions

Define your own action types as plain strings:

from milo import Action

Action("INCREMENT")
Action("ADD_TODO", payload="Buy milk")
Action("SET_THEME", payload="dark")

Action types are just strings. There's no registration step — dispatch any type and handle it in your reducer.