getStream method

Stream<T> getStream(
  1. K id, {
  2. T? initialValue,
  3. bool initiallyNull = false,
})

Get the ValueStreamController for id. If no ValueStreamController exists for id, a new one is created.

Implementation

Stream<T> getStream(
  K id, {
  T? initialValue,
  bool initiallyNull = false,
}) {
  final controller = _controllers[id] ??= ValueStreamController<T>(
    initialValue: initialValue,
    initiallyNull: initiallyNull,
  );

  controller.onCancel = () {
    _controllers.remove(id);
  };

  return controller.stream;
}