RXJava异步代码

Gradle配置

compile "io.reactivex:rxjava:1.1.0"
compile "io.reactivex:rxandroid:1.1.0"

相关代码

Observable.create(new Observable.OnSubscribe<Object>() {
    @Override
    public void call(Subscriber<? super Object> subscriber) {
        //异步操作相关代码
        subscriber.onNext();
    }
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
        .subscribe(new Action1<Object>(){

            @Override
            public void call(Object data) {
                 // 主线程操作
            }
        });

你可能感兴趣的:(异步,rxjava)