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

Cancel the network request in ondestroy() of the activity, should you consider it #26

Open
cornucopib opened this issue Jun 20, 2018 · 3 comments

Comments

@cornucopib
Copy link

No description provided.

@TonnyL
Copy link
Owner

TonnyL commented Jun 20, 2018

Hi, @Vector-SMG

I cannot understand what do you mean, because I do not make any network request in Activity. All the network requests are sending in Fragment. But like you point out, cancelling the request when the activity or fragment is going to destroy is necessary. If you find anything wrong about that, show me more details so I can fix it.

@cornucopib
Copy link
Author

@TonnyL 在Activity或者fragment的onDestroy()的生命周期中,有可能当前界面中,还存在网络请求在执行,导致内存溢出或者空指针异常等等。所以取消网络请求是必要的,当前主流做法:1.如果网络请求中,用到rxjava,使用RxLifecycle来全局取消 2.使用ViewModel+LiveData来管理。是否考虑将其加入?完善这部分逻辑?

@TonnyL
Copy link
Owner

TonnyL commented Jun 21, 2018

@Vector-SMG 你说的很对, 会考虑你的建议.

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