assume you have an Observable stream of values which pushes a values very fast.
Now let's say you have a subscriber which needs to update a record in a database with the latest values from this observable stream, i.e. a somewhat slow I/O bound consumer.
In other words, imagine
from rx import Observable
obs = Observable.interval(1)
# Whoops. Observable will push values faster than we can consume them here.
sub = obs.subscribe( do_some_io_bound_operation )
Is there any way to "skip" all except for the latest values that the observable creates in between different on_next invocations?
In other words: Assume in the example above, obs starts pushing values 1,2,3... The subscriber invokes do_some_io_bound_operation with value "1". This takes a while - by the time its done, values 2 and 3 are available. But instead of calling do_some_io_bound_operation on both new available values, the subscriber should ideally just skip value "2" and directly move on the value 3.
Bit hard to describe - I hope the intention is clear. Is there any way to achieve this?
I'd suppose .Buffer() goes into the direction - but most applications I've seen just buffer by some fixed number of elements or a timespan, whereas I'd need to buffer dynamically (buffer everything that happens while on_next is being executed)
Thanks