How does the .asLiveData() operator work? Kotlin Flow for Android Development
🎓 Get the full 15+ hour-long Course “Kotlin Coroutines and Flow for Android Development” with a nice discount here: https://www.lukaslechner.com/coroutines-flow-android?source=youtube
👨🎓 Here is the link to the Github Example Repository: https://github.com/LukasLechnerDev/Kotlin-Coroutine-Use-Cases-on-Android
This video explains the differences between the asLiveData operator compared to the collect and launchIn operator.
The terminal operator “asLiveData” converts a flow into a LiveData object.
This video also explains the parameters “context” and “timeoutInMs” that can be passed to asLiveData.
TimeStamps
00:00 – Intro
00:35 – Problem: Flow not canceled when the app is put into the background
03:20 – Naive Solution: manually cancelling the job
07:42 – Problems of the naive Solution
10:17 – Using asLiveData
14:15 – Recap of asLiveData operator
15:55 – asLiveData vs collect vs launchIn
20:00 – context parameter of asLiveData
21:05 – timeoutInMs parameter of asLiveData
➤ Subscribe to the channel: https://www.youtube.com/channel/UCr9FeEqCspjGTiOc3HplCqw?sub_confirmation=1
🌎 Check out my website: https://www.lukaslechner.com
📬 Subscribe to my newsletter: https://www.lukaslechner.com/newsletter/
➤ Follow me on twitter: https://twitter.com/LukasLechnerDev
Comments are closed.