once<T extends VyuhEvent> abstract method

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

Subscribe to a single occurrence of an event of type T.

The listener will be called only once when an event of type T is emitted, then the subscription will be automatically cancelled. Call the returned function to cancel it before the event arrives.

Example:

vyuh.event.once<AppStartEvent>((event) {
  print('App started at ${event.timestamp}');
});

Implementation

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