on method

Stream<RealtimeEvent> on({
  1. required String collection,
})

Subscribe to a collection -- returns a stream of realtime events. The project is taken from the signed-in user's session; signed out, from publicKey, and only a collection anyone can read delivers. Subscribed while the stream has a listener; any number of listeners share one subscription.

Implementation

Stream<RealtimeEvent> on({required String collection}) {
  final controller =
      _controllers[collection] ??= StreamController<RealtimeEvent>.broadcast(
    onListen: () => _listened(collection),
    onCancel: () => _unlistened(collection),
  );
  return controller.stream;
}