onSubscribe method

  1. @override
  2. @protected
void onSubscribe()

Reinstalls the event source the last listener's departure tore down.

A setup that throws here is reported to the zone rather than thrown out of subscribe: the listener is registered by then, and a throw would lose the handle that removes it — a client's mount listener that could never be unsubscribed, and one more after every remount. The next subscription tries the setup again.

Implementation

@override
@protected
void onSubscribe() {
  if (_cleanup == null) {
    final setup = _setup;
    if (setup != null) {
      try {
        setEventListener(setup);
      } catch (error, stackTrace) {
        Zone.current.handleUncaughtError(error, stackTrace);
      }
    }
  }
}