The goal is to go through a small example where we move from Dagger and Hilt to kotlin-inject - if you’d be interested in taking a look at something like this in a real app, you can check Chris Banes’ migration PR on his Tivi app. There are certainly other options besides kotlin-inject and Koin, but the scope here will be limited to exploring the option we found to be the best pick for us. However, kotlin-inject is obviously fully written in Kotlin, so it takes full advantage of what the language has to offer and delivers a delightful idiomatic (and yet familiar) API. That second point might sound counterintuitive since many people will opt for Koin exactly because of Dagger's "verbose" API. adding a class to the graph by simply annotating it with kotlin-inject will fit like a glove. Not as important as the previous reason, but if you like the good parts of Dagger (e.g. Nothing beats compile-time dependency graph validation and no runtime crashes. Compile-time safety - basically the same reason as to why someone would pick Dagger or Hilt instead of Koin for an Android project.So why shouldn't we stick with it? Koin is definitely a valid option, but here are the reasons why we chose kotlin-inject instead: Koin is a significantly more popular library, it's currently what's in KaMP Kit, and there are many reasons why one may want to use it. The goal of this article is to make it easy for anyone coming from Dagger or Hilt to adopt kotlin-inject by going through and exploring their differences.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |