I'm looking for an observable selector with a signature akin to this:
static IObservable<T> TakeLatest(this IObservable<T> input, TimeSpan interval)
Which should:
- Emit the first item as soon as input emits its first item
- From then on, in fixed time intervals afterwards, emit the most recent item produced by input
- Complete (or fail) whenever input completes (or fails)
In terms of marbles, something like the following - assuming interval = 2 time units:
Time | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Input | A | B | C | D | E | F (complete) | |||||||||
Output | A | B | D | D | E | E | complete (F not emitted anymore) |
Is there any out-of-the-box way of doing so, or a reasonably easy selector to produce these results?