Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
If you want to check the full code on Github: https://github.com/hichamboushaba/FlowLifecycle
As you can see, using kotlin Flows on the UI layer is still not always straightforward, but still, I prefer it over LiveData, to have access to all its APIs, and for a consistent API accross all layers, for the issue we discussed here, I personally just put the explained logic in a BaseFragment/BaseViewModel, and then I can use it in all the screens without any boilerplate. Let's hope that this feature request gets implemented to offer a way to pause the collection cooperatively without cancelling it, which would fix the issue completely.
Related posts
- Gradle: from Newbie to Strong fundamentals
- Add `statefulMap` and `statefulTransform` operator to Kotlin coroutines' Flow
- Should I choose Kotlin over Java for a new project (backend)?
- kotlinx.coroutines 1.7.0 released
- Is it ok to have global scopes when the coroutine I'm starting has *nothing* to do with showing UI, nor do I care about its result?