values property

  1. @override
Stream<T> get values
override

A Stream of all values on this view, including the current value at the time the stream is listened to.

Implementation

@override
Stream<T> get values {
  // Unlike with `changes`, we're OK here returning an async non-broadcast
  // stream instead of trying to inherit the broadcastness/syncness of the
  // underlying `stream` -- if `stream` were sync, then
  // `ref.values.asBroadcastStream()` would end up yielding the current value
  // before anything could possibly listen to it, which really defeats the
  // point of even calling `values` in the first place.

  late StreamController<T> controller;
  controller = StreamController(onListen: () {
    controller.add(value);
    controller.addStream(stream).then((_) => controller.close());
  });
  return controller.stream;
}