當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。