Kotlin Dependency Injection with the Reader Monad
Jorge Castillo
803

Hi,

great article, very interesting! I really hope that Kotlin will make it easier to apply functional “design patterns” to Android and this is an interesting example.

One question though: It seems that your GetHeroesContext is newly created in the place it is used (and, of course, could be used later on in the same Activity). However, how do/would you handle cases where your Context needs to include longer lived components like an OkHttpClient, basically everything that would have a Singleton annotation in Dagger? Would you have an inner Context that is also passed in through another Reader? (Much in the same way that an ActivityComponent is built from an ApplicationComponent and additional Modules in Dagger?)

Thanks for any additional advice!

David

Show your support

Clapping shows how much you appreciated David Mihola’s story.