EventSubscription<T> class

A consumer registration created by EventBus.subscribe.

The subscription owns its delivery state: the buffer, the pause flag and the error routing. The node only fans events out to offer; it never inspects or drops them itself.

A subscription with onEvent is a listener. The handler capability is added by a later 4.0.0 task; EventSubscription is the type that will carry both.

Properties

address → String
The address (or pattern string) of this subscription.
no setter
bufferCapacity → int?
null means unbounded.
no setter
buffered → int
Events waiting in the subscription buffer.
no setter
bufferedRequests → int
Requests waiting in this subscription's FIFO queue.
no setter
bufferOverflow → BufferOverflow
The current overflow policy.
no setter
cancelOnError → bool
Cancel the subscription after the first listener error.
final
capturePayloads → bool
Attach the event to listener errors. Off by default; set by the bus when ObservabilityConfig.capturePayloads is on.
final
delivered → int
Events passed to onEvent so far.
no setter
deliveryMode → DeliveryMode
Delivery timing; see DeliveryMode.
final
dropped → int
Events dropped by the overflow policy so far.
no setter
handler → Handler<T>?
The request handler. Null means this subscription is not a responder.
final
handlerConcurrency → int
How many handler invocations may run at the same time.
final
hasHandler → bool
Whether this subscription can answer requests.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListener → bool
Whether this subscription can receive events right now.
no setter
hasRequestCapacity → bool
Whether a request can be accepted now: a free handler slot or queue room.
no setter
inFlight → int
Handler invocations currently running.
no setter
isBusy → bool
True while the listener is busy or the handler has no free slot.
no setter
isCanceled → bool
True after cancel or node disposal.
no setter
isHandlerBusy → bool
True when every handler slot is occupied.
no setter
isListenerBusy → bool
True while an asynchronous onEvent future is pending.
no setter
isPaused → bool
True when pause was called and resume has not.
no setter
maxBufferedRequests → int
The largest request queue depth observed.
no setter
onBusError → void Function(EventBusError error)
Receives errors that have no subscription-level handler.
final
onCancel → void Function()
Called when the subscription is cancelled explicitly.
final
onDone → void Function()?
Called when the node is disposed, not when the user cancels.
final
onError → void Function(Object error, StackTrace? stackTrace)?
Optional subscription-level error handler.
final
onEvent → EventCallback<T>?
The listener callback. Null means this subscription is not a listener.
final
queueWaitLatency → LatencySnapshot?
Queue-wait latency, recorded only when trackMetrics is on.
no setter
requestQueueCapacity → int
How many requests may wait in this subscription's FIFO queue.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selector → EventSelector<T>
The typed selector this subscription is attached to.
final
stream → Stream<T>
A broadcast view of the events delivered to this subscription.
no setter
trackMetrics → bool
Track queue depth and queue-wait latency for the metrics snapshot.
final

Methods

acceptsData(Object? data) → bool
Whether data is of the handler's type.
cancel() → Future<void>
Cancels the subscription: the node stops fanning events out to it and its buffer is cleared. onDone is not called; node disposal calls it.
invokeRequest(EventDTO dto, Object? lastData) → Future
Invokes the handler with a typed DTO and the previous value snapshot.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
offer(T event) → bool
Offers an event to the subscription. Returns false when the subscription rejects it (overflow with BufferOverflow.reject), true otherwise.
pause() → void
Stops delivering new events. Buffered events stay until resume or cancel.
resize(int? capacity, {BufferOverflow? overflow}) → void
Changes the buffer size and/or policy at runtime.
resume() → void
Resumes delivery from the buffer.
toString() → String
A string representation of this object.
override

Operators

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