Listener class

Listener is one who listen for specific event. Listener register for notification with EventEmitter Once the listener is registered, a Listener interface is returned back to the caller. Caller can use this Listener interface to cancel the registration or check the state.

Constructors

Listener(String eventName, Object? context, EventCallback callback, CancelEvent? _cancelCallback)
Constructor for Listener. This will take four arguments. eventName, callback are mandatory. context, _cancelCallback are optional. if _cancelCallback callback is provided, then the listener can use that to cancel the subscription.
Listener.Default(String eventName, Object? context, EventCallback callback)
Constructor for Listener. This will take four arguments. eventName, callback are mandatory. context is optional.

Properties

callback EventCallback
The event callback, which the subscriber uses when he register it for.
final
context Object?
The context from which subscriber is interested in.
final
eventName String
The event name, the subscriber subscribed to.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancel() bool
Cancel the event subscription with the subject. Eventhough the cancel method is called, listener doesn't check the cancellation of the subscription. Subscription cancellation shall be implemented in the _cancelCallback function. The Default constructor doesn't provide a mechanism to cancel the subscription. Use the EventEmitter.on to cancel the suscrition effectively. Returns true, if _cancelCallback is successfully executed, false otherwise.
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