on<T extends VyuhEvent> abstract method

DisposeFunction on<T extends VyuhEvent>(
  1. VyuhEventListener<T> listener
)

Subscribe to events of type T.

Returns a dispose function that can be called to cancel the subscription. The listener will be called whenever an event of type T is emitted.

Example:

final dispose = vyuh.event.on<UserEvent>((event) {
  print('User event: ${event.name}');
});

Implementation

DisposeFunction on<T extends VyuhEvent>(VyuhEventListener<T> listener);