How To Implement The Event Bus Pattern With Kotlin SharedFlow In Your Android App
Вставка
- Опубліковано 6 вер 2024
- Medium article:
/ how-to-implement-the-e...
Are you an Android developer looking to learn about event-driven architecture? In this UA-cam video, we'll be discussing the Event Bus design pattern, which is commonly used in Android apps to achieve an event-driven architecture. While it has been largely replaced by Kotlin and other frameworks like Flow, RxJava, and LiveData, with the introduction of SharedFlows and StateFlows, it got way easier to implement the Event Bus pattern. We'll also be comparing the Observer with it and demonstrate how to use SharedFlows to implement the Event Bus design pattern in the context of Android development.
Support me on Medium:
/ membership
Follow me on:
Twitter: / yanneckreiss
Instagram: / yanneckreiss
#android #kotlin #androiddevelopment #programming
Why not just use a normal suspending function to consume in this case only one event rather than a flow?
using this tonight lol. Need to knock out POC by tomorrow. This is part of it.
Good luck, you can do it 😎👍
Amazing content! Thank you for sharing your advice with the community :)
amazing, keep up the great work!
This is awesome, thank you!
i still endorse the old event bus over just about every other pattern. apps have increasing richer and richer widgets that peek at multiple types in the model i.e. an update to a type in the model has an impact in multiple widgets in multiple screens. and you dont know which one will be the first to request an update (the app will not always open by user clicking the icon!!!) e.g. you have a friend list in a friend screen, but on the main screen you may have a menu "Friends 145", a wild notification "12 frends are interested in x" etc. i would never use observable pattern because it short-circuits the response to the source of the request. and to implement this pattern over and over, i would call this much more verbose actually. i would maybe only use observable/livedata/rx if i am bursted updates through a websocket and i consume them all in one place e.g. a list of stock tickers
Thank you bro.
awesome!!
nice
Thanks
Can you share the source code ?