本文整理汇总了Java中io.reactivex.Observable.observeOn方法的典型用法代码示例。如果您正苦于以下问题:Java Observable.observeOn方法的具体用法?Java Observable.observeOn怎么用?Java Observable.observeOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Observable
的用法示例。
在下文中一共展示了Observable.observeOn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_edit, container, false);
unbinder = ButterKnife.bind(this, view);
((MarkdownApplication) getActivity().getApplication()).getComponent().inject(this);
Observable<String> obs = RxTextView.textChanges(markdownEditor)
.debounce(50, TimeUnit.MILLISECONDS).map(CharSequence::toString);
obs.subscribeOn(Schedulers.io());
obs.observeOn(AndroidSchedulers.mainThread());
obs.subscribe(markdown -> {
presenter.onMarkdownEdited(markdown);
});
return view;
}
示例2: applyObservableMainThread
import io.reactivex.Observable; //导入方法依赖的package包/类
public <T> ObservableTransformer<T, T> applyObservableMainThread() {
return new ObservableTransformer<T, T>() {
@Override
public ObservableSource<T> apply(Observable<T> observable) {
return observable.observeOn(AndroidSchedulers.mainThread());
}
};
}
示例3: get
import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, SuperVolley volley) {
if (getRawType(returnType) != Observable.class) {
return null; // Ignore non-Observable types.
}
// Look up the next call adapter which would otherwise be used if this one was not present.
//noinspection unchecked returnType checked above to be Observable.
final CallAdapter<Object, Observable<?>> delegate =
(CallAdapter<Object, Observable<?>>) volley.nextCallAdapter(this, returnType,
annotations);
return new CallAdapter<Object, Object>() {
@Override
public Object adapt(Call<Object> call) {
// Delegate to get the normal Observable...
Observable<?> o = delegate.adapt(call);
// ...and change it to send notifications to the observer on the specified scheduler.
return o.observeOn(scheduler);
}
@Override
public Type responseType() {
return delegate.responseType();
}
};
}