本文整理汇总了Java中io.reactivex.Flowable.observeOn方法的典型用法代码示例。如果您正苦于以下问题:Java Flowable.observeOn方法的具体用法?Java Flowable.observeOn怎么用?Java Flowable.observeOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Flowable
的用法示例。
在下文中一共展示了Flowable.observeOn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postToObservable
import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
* 用于处理订阅事件在那个线程中执行
*
* @param observable d
* @param subscriberMethod d
* @return Observable
*/
private Flowable postToObservable(Flowable observable, SubscriberMethod subscriberMethod) {
Scheduler scheduler;
switch (subscriberMethod.threadMode) {
case MAIN:
scheduler = AndroidSchedulers.mainThread();
break;
case NEW_THREAD:
scheduler = Schedulers.newThread();
break;
case CURRENT_THREAD:
scheduler = Schedulers.trampoline();
break;
default:
throw new IllegalStateException("Unknown thread mode: " + subscriberMethod.threadMode);
}
return observable.observeOn(scheduler);
}
示例2: applyFlowableMainThread
import io.reactivex.Flowable; //导入方法依赖的package包/类
public <T> FlowableTransformer<T, T> applyFlowableMainThread() {
return new FlowableTransformer<T, T>() {
@Override
public Publisher<T> apply(Flowable<T> flowable) {
return flowable.observeOn(AndroidSchedulers.mainThread());
}
};
}
示例3: applyFlowableAsysnc
import io.reactivex.Flowable; //导入方法依赖的package包/类
public <T> FlowableTransformer<T, T> applyFlowableAsysnc() {
return new FlowableTransformer<T, T>() {
@Override
public Publisher<T> apply(Flowable<T> flowable) {
return flowable.observeOn(AndroidSchedulers.mainThread());
}
};
}
示例4: applyFlowableCompute
import io.reactivex.Flowable; //导入方法依赖的package包/类
public <T> FlowableTransformer<T, T> applyFlowableCompute() {
return new FlowableTransformer<T, T>() {
@Override
public Publisher<T> apply(Flowable<T> flowable) {
return flowable.observeOn(AndroidSchedulers.mainThread());
}
};
}