subscribe<Event> method

void subscribe<Event>(
  1. void handler(
    1. Event event
    ), {
  2. bool handleError = true,
  3. ErrorCallback? onError,
})

安全订阅事件,自动管理生命周期

Implementation

void subscribe<Event>(
  void Function(Event event) handler, {
  bool handleError = true,
  ErrorCallback? onError,
}) {
  _eventSubscriptions.add(
    EventBusUtils.on<Event>(
      handler,
      handleError: handleError,
      onError: onError,
    ),
  );
}