Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xhttp 请求生命周期绑定 #29

Closed
querli opened this issue Dec 14, 2021 · 3 comments
Closed

Xhttp 请求生命周期绑定 #29

querli opened this issue Dec 14, 2021 · 3 comments

Comments

@querli
Copy link

querli commented Dec 14, 2021

你好,我阅读了文档,网络请求生命周期和Activity/Fragment生命周期绑定,请问在XHTTP请求中如何使用RxJava的compose的操作符进行绑定?Xhttp请求中无法调用compose函数

@xuexiangjys
Copy link
Owner

正常XHttp请求都可以啊,文档里都有啊,下面是上传的请求,里面就有啊

mIProgressLoader.updateMessage("上传中...");
XHttp.post("/book/uploadBookPicture")
        .params("bookId", book.getBookId())
        .uploadFile("file", FileUtils.getFileByPath(mPicturePath), new IProgressResponseCallBack() {
            @Override
            public void onResponseProgress(long bytesWritten, long contentLength, boolean done) {

            }
        }).execute(Boolean.class)
        .compose(RxLifecycle.with(this).<Boolean>bindToLifecycle())
        .subscribeWith(new ProgressLoadingSubscriber<Boolean>(mIProgressLoader) {
            @Override
            public void onSuccess(Boolean aBoolean) {
                mIsEditSuccess = true;
                ToastUtils.toast("图片上传" + (aBoolean ? "成功" : "失败") + "!");
            }
        });

@querli
Copy link
Author

querli commented Dec 15, 2021

好吧,我使用了execute(CallBack callBack)这个直接返回的是Disposable类型,所以无法绑定生命周期compose函数

@querli
Copy link
Author

querli commented Dec 28, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants