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