-
Notifications
You must be signed in to change notification settings - Fork 92
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
怎么手动取消网络请求,或是在按手机返回键时取消网络请求 #3
Comments
viewmodel在Activity销毁时不会导致内存泄露的 |
这个我知道。我是想,当请求过程中,弹出dialog,但我手动按手机返回键,取消掉dialog,顺便也终止网络请求。不知道这个怎么搞 |
看了看可以修改launchFlow方法,使用onEach和launchIn操作符,返回job对象,取消的时候调用job.cancel |
如果在这个项目中要实现这个功能,需要在封装一些功能。 |
UNKNOWN_ERROR:kotlinx.coroutines.JobCancellationException: Job was cancelled; job=SupervisorJobImpl{Cancelling}@a277d95msgJob was cancelledname:JobCancellationException 取消会报异常 |
UNKNOWN_ERROR:kotlinx.coroutines.JobCancellationException: Job was cancelled; job=SupervisorJobImpl{Cancelling}@a277d95msgJob was cancelledname:JobCancellationException 取消会报异常 |
No description provided.
The text was updated successfully, but these errors were encountered: