Intents, flows & manager
This chapter covers what the UI asks for (OmegaIntent), who coordinates (OmegaFlow), and who routes work (OmegaFlowManager).
OmegaIntent
An intent is a named request with optional payload.
- Enum + optional DTO —
OmegaIntent.fromName<YourDto>(AppIntent.someCase, payload: dto)(static method). The genericYourDtochecks the payload at compile time when you pass it. - One object = wire + data — implement OmegaTypedIntent (same
nameas the matchingAppIntent/ module intent wire). UI callsflowManager.handleTypedIntent(myTypedIntent); flows readctx.intent?.typedPayloadAs<MyTypedIntent>().
The UI (or tests) send intents through flowManager.handleIntent(…) or flowManager.handleTypedIntent(…) — the manager forwards to every flow in OmegaFlowState.running (see example/lib/auth/ui/auth_page.dart).
OmegaFlow
Subclass OmegaFlow, pass super(id: …), and implement:
onIntent— react to intents routed while this flow is running (login submit, refresh, …).onEvent— react to channel events (often emitted by agents).
Emit expressions for UI state via emitExpression(type, payload) and drive navigation by emitting the same navigation events / intents the OmegaNavigator listens for (see Navigation & routes).
Lifecycle: idle → running (via activate / switchTo) → paused / sleeping / ended. Only running flows receive intents in the default routing.
OmegaFlowManager
| Method | Use |
|---|---|
registerFlow | Register once at bootstrap. |
activate(id) | Add a flow to the running set (multi-flow). |
switchTo(id) | Single “main” flow: activates one and pauses others. |
handleIntent | Entry point from UI with a built OmegaIntent. |
handleTypedIntent | Same, but argument implements OmegaTypedIntent — wire + payload are one object (API). |
wireNavigator | Called by OmegaRuntime.bootstrap — connects navigation traffic on the channel. |
Lightweight handlers (optional)
For small features you can register registerIntentHandler, Omega.handle, OmegaIntentReducer, or OmegaIntentHandlerPipeline via OmegaConfig.intentHandlerRegistrars — handlers run before intents reach running flows; consumeIntent: true skips flow delivery.
UI rule of thumb
Widgets emit intents and listen to expressions (or OmegaFlowExpressionBuilder). They do not call repositories or imperative services for feature coordination — that belongs in flows and agents.
Full example
Walk through example/lib/auth/auth_flow.dart, auth_page.dart, and omega_setup.dart on GitHub.