Summary
In this chapter, we got our feet wet by creating our own operators. It is preferable to use ObservableTransformer
and FlowableTransformer
to compose existing operators together to create new ones, and even with that, you need to be cautious when introducing stateful resources that cause undesirable side-effects. When all else fails, you can create your own ObservableOperator
or FlowableOperator
and create an operator at a low level that intercepts and relays each emission and event. This can be tricky and you should exhaust all other options, but with careful study and testing, creating operators can be a valuable advanced skill to have. Just be careful to not reinvent the wheel and seek guidance from the Rx community as you start dabbling in custom operators.
If you truly are interested in implementing your own operators (at a low level, not with Transformers), definitely study existing operators in RxJava and other reputable RxJava extension libraries. It is easy to hack an operator...