rxjava 2.0 what is the difference between Observable.subscribe and Observable.subscribeActual?

試著忘記壹切 提交于 2019-12-11 17:56:35

问题


The documentation just says

protected abstract void subscribeActual(Observer<? super T> observer) Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic. There is no need to call any of the plugin hooks on the current Observable instance or the Subscriber.


回答1:


Observable.subscribe comes from the base interface definition in ObservableSource and is the main subscription method for Observables: internal and external components use it to run a flow in a standard way.

However, certain actions may be necessary for all kinds of Observables to be executed before the operator's business logic gains access to the incoming Observer, for example, applying plugin hooks and protecting against crashing subscribe implementations. So instead of requiring every operator to duplicate this preparation logic, they are in a single place and a new abstract method is present to deal with the customization of an Observable.



来源:https://stackoverflow.com/questions/44714124/rxjava-2-0-what-is-the-difference-between-observable-subscribe-and-observable-su

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!