OnEvent class

Annotation to mark a method as an event handler.

Used by code generation to automatically register event handlers.

class User extends Model<User> {
  @OnEvent(ModelCreatingEvent)
  static void beforeCreate(ModelCreatingEvent event) {
    event.attributes['created_at'] = DateTime.now();
  }

  @OnEvent(ModelCreatedEvent)
  void afterCreate(ModelCreatedEvent event) {
    sendWelcomeEmail(this);
  }
}
Implementers

Constructors

OnEvent(Type eventType)
const

Properties

eventType Type
The event type this handler responds 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

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