OmegaFlow class abstract

Business flow (login, checkout, etc.): orchestrates events, intents and communication with the UI.

Why use it: Centralizes use-case logic. Listens to channel events and UI intents; decides which expressions to emit and when to navigate. The UI only listens to expressions.

Example: In onIntent you receive credentials, emit "loading", ask the agent to login; in onEvent you receive "auth.login.success" and emit "success" + navigation intent.

Only processes when state is OmegaFlowState.running. Activated via OmegaFlowManager.activate or switchTo.

Implementers

Constructors

OmegaFlow({required String id, required OmegaEventBus channel})

Properties

channel OmegaEventBus
Event bus (channel or OmegaChannelNamespace); the flow listens to channel.events and can emit events.
final
contract OmegaFlowContract?
Optional declarative contract: events listened, intents accepted, expression types emitted. When set, in debug mode Omega warns if the flow receives or emits something not declared. Override in subclasses to declare contracts. Default is null (no validation). Cached on first access so prefer returning a const or stable instance.
no setter
expressions Stream<OmegaFlowExpression>
Stream the UI listens to for updates (loading, success, error, etc.).
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
Flow identifier (e.g. "authFlow"). Must match the one used in the manager.
final
memory Map<String, dynamic>
Flow memory (key/value). Persists while the flow is active; can be restored with restoreMemory.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state OmegaFlowState
Current state. onEvent and onIntent are only called when OmegaFlowState.running.
getter/setter pair

Methods

emitExpression(String type, {dynamic payload}) → void
Notifies the UI of a state change (loading, success, error). The UI listens to expressions.
end() → void
Ends the flow and closes its streams. Unsubscribes from the channel so no further events are delivered.
getSnapshot() OmegaFlowSnapshot
Snapshot of current state (id, state, memory, last expression). For debugging, persistence or restore.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onEnd() → void
onEvent(OmegaFlowContext ctx) → void
Implement the reaction to channel events (e.g. "auth.login.success"). Only called when the flow is running.
onIntent(OmegaFlowContext ctx) → void
Implement the reaction to intents (e.g. login, logout). Only called when the flow is running.
onPause() → void
onSleep() → void
onStart() → void
onWakeUp() → void
pause() → void
Pauses the flow temporarily.
receiveIntent(OmegaIntent intent) → void
Sends the intent to this flow. Only processed if state is running; then onIntent is called.
restoreMemory(Map<String, dynamic> data) → void
Replaces memory with data. Use after loading a snapshot (restore on launch).
sleep() → void
Puts the flow in "sleep" mode, reducing activity but keeping state.
start() → void
Puts the flow in OmegaFlowState.running and calls onStart. Invoked by the manager (activate/switchTo).
toString() String
A string representation of this object.
inherited
wakeUp() → void
Wakes up a flow that was in sleep mode.

Operators

operator ==(Object other) bool
The equality operator.
inherited