locke
11/12/2018, 6:34 PMObservable
by a filter without subscribing more than once? I have a sealed class that represents an Event
, but I need to filter the results to various handlers. My naive method was:
val eventStream: Observable<Event> = getEventStream() // Observable representing long running operation
eventStream
.filter { it is Event.Success }
.subscribe {
// Handle success
}
eventStream
.filter { it is Event.Failure }
.subscribe {
// Handle failure
}
There are more cases, but the problem is described in these. I don't want to kick off the long running operation twice, which this seems like it would do.