I'd like to calculate a difference between emissions of a single Observable.
Is there a way to get both the current and previous emission of an Observable if it emits a new value? I'd like something like this:
ob$.subscribe(val => {
console.log(val)
// First emission: [1,2,3]
// Second emission: [1,2,3,4]
console.log(arrayDifference(before, after)) // [4]
})
How would I go about that? Do I need to store every emission in an upper-scope variable or is there a fancy RxJS way to do this?
Read more here: https://stackoverflow.com/questions/65709840/rxjs-get-before-after-emission-values-of-observable
Content Attribution
This content was originally published by dmuensterer at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.