I need to make a function that takes in a RXJS stream and return an accumulated result for last x minute (or a given timerange) I think this is probably easier to explain if I give an example:
I'll try to illustrate what I want with marble diagrams:
I want to get the accumulated result for the last minute (60 seconds):
Stream: [---a---b---c---a--->
1 min in time: [-------------------]
Result: {a:2, b: 1, c:1}
After a couple of ms:
Stream: [---a---b---c---a----a----a>
1 min in time: [-------------------]
Result: {a:3, b: 1, c:1}
After a couple of ms:
Stream: [---a---b---c---a----a----a----a-->
1 min in time: [-------------------]
Result: {a:4, b: 0, c:0}
After a couple of ms:
Stream: [---a---b---c---a----a----a----a---c---c>
1 min in time: [-------------------]
Result: {a:3, b: 0, c:2}
After a couple of ms:
Stream: [---a---b---c---a----a----a----a---c---c-----c-->
1 min in time: [-------------------]
Result: {a:1, b: 0, c:3}
It should emit a new result every time the accumulated result changes. (So when new value comes in to the result or when a old value pops out of the result)