-
-
Notifications
You must be signed in to change notification settings - Fork 598
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
Use Coroutine in PageFragmentLoadState #4649
Conversation
.doAfterTerminate { pageLoadFromNetwork { fragment.onPageLoadError(it) } } | ||
.subscribe()) | ||
clientJob?.cancel() | ||
clientJob = CoroutineScope(Dispatchers.Main).launch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CoroutineScope can be passed into this class from the parent PageFragment's lifecycleScope
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
I also removed the try-catch
and used CoroutineExceptionHandler
. It now shows a different error message "There was a network error.` vs. the original one "Cannot connect to internet" with a more detailed error message. Which one do we want to use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: after switching to use the lifecycleScope
from parentFragment, the try-catch
will cause a crash 🤔
Merging, since I will have a follow-up. |
This is a related PR for the upcoming
PageFragment
andPageActivity
ViewModel work,