Subscribe-Analyse
2020-12-14 14:58:51 0 举报
Rxjava-subscribe
作者其他创作
大纲/内容
1 :1
ObservableEmitter<T>
+ setDisposable(@Nullable Disposable d): void+ setCancellable(@Nullable Cancellable c): void+ isDisposed(): boolean+ tryOnError(@NonNull Throwable t): boolean+ serialize(): ObservableEmitter<T>
发射器,用于向观察者发送数据
ObservableOnSubscribe<T>
+ subscribe(@NonNull ObservableEmitter<T> emitter) throws Exception
ObservableCreate
+ ObservableOnSubscribe<T> source;
+ subscribeActual(Observer<? super T> observer) // 实现
观察者 Observer
Disposable
+ dispose(): void+ isDisposed(): boolean
Observable 用于创建一个被观察者create 方法创建出得被观察者是 ObservableCreateObservableCreate 是对 ObservableOnSubscribe 的封装,ObservableOnSubscribe 用于发送被订阅的数据,可以理解为真正的、实际的被观察者
Observer<T>
+ onSubscribe(@NonNull Disposable d): void+ onNext(@NonNull T t): void+ onError(@NonNull Throwable e): void+ onComplete(): void
1 : 1
Emitter<T>
+ onNext(@NonNull T value): void+ onError(@NonNull Throwable error): void+ onComplete(): void
Observable
+ create(ObservableOnSubscribe<T> source): Observable<T>+ subscribe(Observer<? super T> observer): void+ subscribeActual(Observer<? super T> observer): abstract void
CreateEmitter<T>
+ observer: Observer<? super T>
+ onNext(@NonNull T value): void+ onError(@NonNull Throwable error): void+ onComplete(): void+ setDisposable(@Nullable Disposable d): void+ setCancellable(@Nullable Cancellable c): void+ isDisposed(): boolean+ tryOnError(@NonNull Throwable t): boolean+ serialize(): ObservableEmitter<T>
发射器会将 Observer 包在内部,数据的流向会从 CreateEmitter 到 Observer。CreateEmitter.onNext --> Observer.onNext CreateEmitter.onComplete --> Observer.onCompleteCreateEmitter.onError --> Observer.onError
0 条评论
下一页