stream<O> method

Stream stream<O>({
  1. required ListenCli listenCli,
  2. required StreamSource source,
  3. 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);
}