EventContext class

Context information for a table change event

Wraps an Event with the current client's connection ID, providing convenience methods and helpers for common operations.

The context allows event handlers to:

  • Access transaction metadata (timestamp, reducer name, caller, etc.)
  • Check if the transaction was initiated by the current client

Example:

noteTable.insertEventStream.listen((event) {
  final ctx = event.context;

  if (ctx.isMyTransaction) {
    print('I created this note!');
  } else {
    print('Someone else created this note');
  }

  // Access event metadata
  if (ctx.event is ReducerEvent) {
    final reducerEvent = ctx.event as ReducerEvent;
    print('Reducer: ${reducerEvent.reducerName}');
  }
});

Constructors

EventContext({required Uint8List? myConnectionId, required Event event, bool isOptimistic = false, String? pendingRequestId})
EventContext.optimistic({required String requestId})

Properties

event Event
final
hashCode int
The hash code for this object.
no setterinherited
isMyTransaction bool
🌟 GOLD STANDARD: DX Helper - Check if this event was triggered by current client
no setter
isOptimistic bool
final
pendingRequestId String?
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
toString() String
A string representation of this object.
inherited

Operators

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