I see couple approaches: 1. Implement operator fo...
# rx
a
I see couple approaches: 1. Implement operator for say Flowable and then use
toObservable()
,
toSingle()
, etc. Easy, but there is performance cost. 1. Extract common logic to inline functions if possible and use them in each operator implementation for each type. Not that easy, but you’re reusing some code and not actually loosing performance. 1. Just duplicate operator implementation for each type. More work, but you get most flexibility in code and performance. 1. Make common wrapper for Observable/Flowable/Single
*OnSubscribe
types (I assume you use
create(OnSubscribe)
) that proxies calls to underlying emitter and throws exceptions if state is invalid for particular type. This gives you reusability for the code, but you’re loosing performance. However you might be able to use inline functions accurately which will result in less performance penalty.