Open JavierBejMen opened 2 years ago
What about most straightforward way? when you pass all comparisons to one lambda or something like this? like
observable.filter([](int v){return v % 2 == 0 || v > 3 || v ==1;})
another way I can imagine is use amb
operator, but you will need to create it for each obtained value and immediately execute. Like...
observable.flat_map([](int v)
{
return rxcpp::observable<>::just(v)
.filter([](int v){return v % 2 ==0;})
.amb(rxcpp::observable<>::just(v).filter([](int v){return v > 3;}),
rxcpp::observable<>::just(v).filter([](int v){return v == 1;}))
});
but not sure if it is really useful (due to every time for each value you will create new observable, configure and immediately run)
Let's say we have multiple operations, where each operation can succeed or fail. We want to lift a pipeline of observables that sequentially try each operation while they fail, returning as soon as one operation succeed.
That sounds like
Amb(op0.retry(), op1.retry(), ..)
Hi all! We are currently developing an stream processing program using RxCpp, but we are having issues on how to correctly approach the following situation.
Let's say we have multiple operations, where each operation can succeed or fail. We want to lift a pipeline of observables that sequentially try each operation while they fail, returning as soon as one operation succeed.
The main questions is:
One possible implementation we come across is the following:
We define the
OperationResult
class, just a wrapper over the event being processed and a boolean indicating if the operation succeeded or failed:And the
Operation
class, that set up the rxcpp pipeline, where each operation exposes 2 observables, one that emits successfully processed items and one that emits the failed ones.This allows for setting up a
logical OR
between multiple Operations like this:Output:
Any help or insight you can give me is much appreciated!