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

Use Coroutine in PageFragmentLoadState #4649

Merged
merged 12 commits into from May 21, 2024
Merged

Conversation

cooltey
Copy link
Collaborator

@cooltey cooltey commented May 7, 2024

This is a related PR for the upcoming PageFragment and PageActivity ViewModel work,

.doAfterTerminate { pageLoadFromNetwork { fragment.onPageLoadError(it) } }
.subscribe())
clientJob?.cancel()
clientJob = CoroutineScope(Dispatchers.Main).launch {
Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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 🤔

@dbrant
Copy link
Member

dbrant commented May 21, 2024

Merging, since I will have a follow-up.

@dbrant dbrant merged commit f4ae4ea into main May 21, 2024
1 check passed
@dbrant dbrant deleted the page-fragment-load-state-coroutine branch May 21, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants