MagicListener<T extends MagicEvent> class abstract

The base class for all event listeners.

Listeners handle logic when a specific MagicEvent is dispatched. They are intended to decouple side-effects (like sending emails or logging) from the main business logic.

Usage

class SendWelcomeEmail extends MagicListener<UserRegistered> {
  @override
  Future<void> handle(UserRegistered event) async {
    await Mail.to(event.user).send(WelcomeEmail());
  }
}

Constructors

MagicListener()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

handle(T event) Future<void>
Handle the event.
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