stream<O> method
Stream
stream<O>({
- required ListenCli listenCli,
- required StreamSource source,
- required bool persevere,
Implementation
Stream stream<O>({required ListenCli listenCli, required StreamSource source, required bool persevere}) {
logger('> stream (ListeningHandler) -> ${listenCli.route}');
final listener = _getExistingListener(hash: listenCli.hash, source: source) ?? _getNewListener(listenCli);
// TODO: in the future, change this so if there's 3 streams identical, but only one is persevere
// and the persevere stream stops listening, so persevere will change to false
listener.persevere = persevere || listener.isPersevere();
// Important: the logic of converting the stream events
// should be always bellow _getAlreadyListening(..) and _getNewListening(..)
return listener.stream.map((value) => value.output);
}