本文整理匯總了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());
}