I have on Observable, which emits items when some data is coming from a BLE connection:
public interface CommunicationController {
Flowable<DataContainer> dataReceived();
}
On top of this I want to build a Observable, which completes when one of the following conditions is true:
a. I receive two messages of a specific type (this is done by using filter operator on the received DataContainer item.
communicationController.dataReceived()
.filter(data -> isTypeA(data) || isTypeB(data))
.take(2)
.toList()
.map(dataContainers -> doSomeMappingToCommon object)
b. I receive one message of a specific type (again using filter operator).
communicationController.dataReceived()
.filter(data -> isTypeC(data))
.firstOrError()
.map(dataContainers -> doSomeMappingToCommon object);
How can I combine those two Observables into a single one?
Additionally only one of the two Observables will emit an item.