Concurrent Flows with the buffer operator | Kotlin Flow for Android Development



Concurrent Flows with the buffer operator | Kotlin Flow for Android Development

Concurrent Flows with the buffer operator | 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

By default, the execution of a Flow is sequential, since the producer and the collector code run in the same coroutine.

With the buffer operator, we can achieve concurrent flows by decoupling the producer and the emitter. This way, the producer can emit new items even before the collector fully processed the previous item. This works because the producer and the collector now run in their own coroutines.

Items that haven’t yet been processed end up in a buffer.

TimeStamps:
00:00 Intro
00:36 sequential execution by default
04:58 concurrent execution with the buffer operator
07:22 internal workings
09:15 explanation of the buffer

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