1

I have a stream that will either complete or throw an exception (ie. not an infinite stream).

It emits 2 values (say A and B) before it finishes. Is it possible to map the last value emitted to something else?

stream$
    .debounceTime(100)
    .mergeMap(element =>
      api(stream$, ...) // This emits A B
        .last()
        .map(lastElement => f(lastElement.result)) // produces C based on B

Now I have a stream containing just C, is it possible to keep A (so that the $stream emits A C) without resorting to have local variables to store the intermediate stream?

ᴘᴀɴᴀʏɪᴏᴛɪs
  • 7,169
  • 9
  • 50
  • 81

0 Answers0