当前位置: 首页>>代码示例>>Java>>正文


Java Observable.observeOn方法代码示例

本文整理汇总了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;
}
 
开发者ID:wbrawner,项目名称:SimpleMarkdown,代码行数:17,代码来源:EditFragment.java

示例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());
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:RxSchedulers.java

示例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();
        }
    };
}
 
开发者ID:octaware,项目名称:super-volley,代码行数:28,代码来源:ObserveOnMainCallAdapterFactory.java


注:本文中的io.reactivex.Observable.observeOn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。