ingest method
Injest a Stream and add all values emitted from it to this beacon
example:
var beacon = Beacon.writable(0);
var myStream = Stream.fromIterable([1, 2, 3]);
beacon.injest(myStream);
Implementation
void ingest(
Stream<T> source, {
void Function(T)? then,
T? initialValue,
}) {
final internalBeacon = RawStreamBeacon<T>(
() => source,
isLazy: true,
initialValue: initialValue,
shouldSleep: true,
);
wrap(
internalBeacon,
then: then,
startNow: false,
);
internalBeacon.onDispose(() {
_wrapped.remove(internalBeacon.hashCode);
// don't dispose parent beacon because
// internal is disposed when the stream ends
});
onDispose(internalBeacon.dispose);
}