OmegaEvent class

Represents "something that happened" in the system, transmitted via OmegaChannel.

Why use it: Agents and flows react by name; payload carries optional data. Use optional namespace to scope events (e.g. "auth", "checkout") so modules do not collide.

Example: Create with typed name and read payload with type:

channel.emit(OmegaEvent.fromName(AppEvent.authLoginSuccess, payload: user));
// With namespace (e.g. from channel.namespace('auth')):
channel.namespace('auth').emit(OmegaEvent.fromName(AppEvent.authLoginSuccess, payload: user));
Inheritance
Available extensions

Constructors

OmegaEvent({required String id, required String name, dynamic payload, Map<String, dynamic> meta = const {}, String? namespace})
Prefer OmegaEvent.fromName when you have an OmegaEventName — it supplies id when omitted.
const
OmegaEvent.fromName(OmegaEventName eventName, {dynamic payload, String? id, String? namespace, Map<String, dynamic> meta = const {}})
Creates an event with a typed name (enum implementing OmegaEventName). Generates id if not provided.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
id String
Unique object identifier.
finalinherited
meta Map<String, dynamic>
Optional metadata (key-value).
finalinherited
name String
Event name (e.g. "auth.login.success"). Listeners filter by this value.
final
namespace String?
Optional namespace (e.g. "auth", "checkout"). When set, only listeners subscribed to that namespace (or the global stream) receive it. When null, event is global.
final
payload → dynamic
Optional data. Use payloadAs to read with type safety.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
payloadAs<T>() → T?

Available on OmegaEvent, provided by the OmegaEventPayloadExtension extension

Returns payload as T if the runtime value is compatible; otherwise null.
toJson() Map<String, dynamic>
Serializes this event to a JSON-friendly map (e.g. for OmegaRecordedSession trace files). payload and meta should be JSON-serializable when persisting.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

fromJson(Map<String, dynamic> json) OmegaEvent
Creates an event from a map (e.g. from a trace file). payload and meta are read as-is.