Android w/o DI — Update

All about the Flow

Bob Dahlberg
The Startup

--

Photo by Fabio Bracht on Unsplash

In the original post, I used a BroadcastChannel in my AppStream to send messages between different parts of the application. Since Kotlin 1.4, I would suggest that you use the SharedFlow instead.

I’ve done the switch in my applications due to two reasons.

  1. It is designed to replace the BroadcastChannel completely.
  2. Simplifying the code so that everything is a Flow. not forcing developers to know the Channel API.

If you want more reasons, I’d suggest you take a look at this link: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/.

I’ve also updated the example code to use this in a branch named “feat/sharedflow” to reflect those changes.

Here is the updated AppStream, which is the only piece that needs updating for the switch to happen.

--

--

Bob Dahlberg
The Startup

Lead Developer at Qvik, Coach, Agile Thinker, GDG Lead.