SunnyObservableList<V>.ofStream constructor

SunnyObservableList<V>.ofStream(
  1. Stream<Iterable<V>> stream, {
  2. FutureOr<Iterable<V>>? start,
  3. ListDiffAlgorithm? diffAlgorithm,
  4. DiffEquality diffEquality = const DiffEquality(),
  5. String? debugLabel,
})

Implementation

SunnyObservableList.ofStream(Stream<Iterable<V>> stream,
    {FutureOr<Iterable<V>>? start,
    this.diffAlgorithm,
    this.diffEquality = const DiffEquality(),
    String? debugLabel})
    : debugLabel = debugLabel ?? "stream[${V.simpleName}]",
      super() {
  this.sync(start).then((_) {
    final subscription = stream.asyncMap((newList) {
      try {
        log.fine(
            "got sync event from upstream with ${newList.length} records");
        this.sync(newList);
      } catch (e) {
        print(e);
      }
    }).listen(
      (_) {},
      cancelOnError: false,
    );
    disposers.add(subscription.cancel);
  });
}