本文整理汇总了Java中io.reactivex.Observable.fromPublisher方法的典型用法代码示例。如果您正苦于以下问题:Java Observable.fromPublisher方法的具体用法?Java Observable.fromPublisher怎么用?Java Observable.fromPublisher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Observable
的用法示例。
在下文中一共展示了Observable.fromPublisher方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toObservable
import io.reactivex.Observable; //导入方法依赖的package包/类
/**
* Converts DataBinding's ObservableField to RxJava2's Observable
* see https://habrahabr.ru/post/328512/
* @param observableField
* @param <T>
* @return Observable (RxJava2)
*/
public static <T> Observable<T> toObservable(@NonNull final ObservableField<T> observableField) {
return Observable.fromPublisher(asyncEmitter -> {
final android.databinding.Observable.OnPropertyChangedCallback callback = new android.databinding.Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(android.databinding.Observable dataBindingObservable, int propertyId) {
if (dataBindingObservable == observableField) {
asyncEmitter.onNext(observableField.get());
}
}
};
observableField.addOnPropertyChangedCallback(callback);
});
}
示例2: observable
import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
public Observable<T> observable() {
return Observable.fromPublisher(get());
}
示例3: retrieveAllRx
import io.reactivex.Observable; //导入方法依赖的package包/类
/**
* Same as {@link #retrieveAll()} but wrapped in a {@link Observable}.
*
* @return Observable that when subscribed will retrieve the key value pairs stored in
* {@link Hoard} and provide them as a {@link Hoard.Pair}
*/
public Observable<Hoard.Pair> retrieveAllRx() {
return Observable.fromPublisher(hoard.retrieveAllReactive());
}