pipe method

Future pipe (StreamStore<T> streamStore)

Pipes the events of this stream into streamStore.

All events of this stream are added to streamStore using StreamStore.addStream. The streamStore is closed when this stream has been successfully added to it - when the future returned by addStream completes without an error.

Returns a future which completes when this stream has been consumed and the Store has been closed.

The returned future completes with the same result as the future returned by StreamStore.close. If the call to StreamStore.addStream fails in some way, this method fails in the same way.

Implementation

Future pipe(StreamStore<T> streamStore) {
  return streamStore.addStream(this).then((_) => streamStore.close());
}