Eventbus in Kotlin with Rx
EventBus is a design pattern which allows publish-subscribe style communication without requiring components to registering with each other. Most of the android developers have used a library for EventBus
. EventBus by Greenrobot is a pretty famous library and widely used. It was quite impressive how you could send any object and the subuscriber would receive it without any hassles.
Kotlin has been on the rise since past couple of years, especially for android app development. I also started learning the language by making an app. I required EventBus
so I thought of implementing it myself in Kotlin with the help of Rx (RxKotlin) and it turned out to be super short and quite easy.
That’s it! It’s that simple. And this is how I use it.
reified
It means to make something, which is abstract, concrete or real. When we need to access the type passed in the parameter, we can use reified
type parameters which gives us run-time access to types passed to the function. Read more about it - reified specs.
Redux architecture and Android
Learn the Redux architecture and implement the clean architecture it in your Android codebase. This series of posts explores the depth of Redux and guides you through implementing the architecture in Kotlin for your android app.