onStart & onCompletion Lifecycle Operators | Kotlin Flow for Android Development



onStart & onCompletion Lifecycle Operators | Kotlin Flow for Android Development

onStart & onCompletion Lifecycle Operators | 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

In this video, you will learn all about the lifecycle operators “onStart” and “onCompletion”.

With the onStart operator, we can define an action that is performed right before the flow gets collected. It is important to mention, that the action in the onStart operator is invoked as soon as the collection on the flow starts, and not when the first item is emitted.

The other lifecycle operator is “onCompletion”. It allows us to specify an action that is executed after the flow completes. A flow can either complete normally, so when all the values of the flow got emitted, or exceptionally, when the flow throws an exception.

For our lifecycleOperators “.onStart()” and “onCompletion” its important to note, that these operators can be installed at any position within the flow processing pipeline.

TimeStamps
00:00 – Intro
00:20 – Problem Description
01:00 – Lifecycle Operators
01:25 – onStart
02:12 – onCompletion
06:42 – emit in lifecycle operators
08:44 – onStart documentation
10:48 – onEach
12:00 – map
14:15 – Solution
14:44 – Summary

➤ 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.