SunnyObservableList<V>.ofVStream constructor

SunnyObservableList<V>.ofVStream(
  1. ValueStream<Iterable<V>> stream, {
  2. DiffEquality diffEquality = const DiffEquality(),
  3. String? debugLabel,
})

Implementation

SunnyObservableList.ofVStream(ValueStream<Iterable<V>> stream,
    {this.diffEquality = const DiffEquality(), String? debugLabel})
    : debugLabel = debugLabel ?? "stream[${V.name}]",
      super() {
  this.sync(stream.get()).then((_) {
    final subscription = stream.listen(
      (newList) {
        try {
          log.info(
              "[$debugLabel] got sync event from upstream with ${newList.length} records");
          this.sync(newList);
        } catch (e) {
          print(e);
        }
      },
    );
    disposers.add(subscription.cancel);
  });
}