Koin Framework — Qualifiers(Part-6) — Most Underrated Framework🤔

Hey guys this is gonna be the Sixth part on Koin Framework , where we will discuss about Qualifiers in Koin Framework.😎

You can also read the below articles on Koin Framework

What does Qualifier means?

Qualifiers is nothing it’s a way to give different-different implementation of same thing. Suppose you have two variables FirstName and LastName which returns String, So how will you provide the dependency of both String?.🤔

When you go to provide the dependency of both String , Koin will confused like how i provide the dependency?, how i identify? , which one dependency has been provided.😚

That’s why Qualifier comes as solution, it will give the different tag names to both String so that it will be easier for koin to identify and provide the dependency. Let’s start with the example for better understanding 😉👌

In the above code we have a Users class , which takes two String class as a Parameter , Let see how to you provide the dependency of both String , for that we have to create a module file.😊

In the above code we have a module , where we provide dependency. Through factory function we have provided the dependency injection of FirstName with a unique tag name on named() function. In the same way we provide the dependency of LastName and at the last pass these String dependency in Users class.❤

This is how we use the qualifiers , You can also use with Retrofit ,Room , Firebase or other external libraries in the same way , if you want two or more different implementation.🥰

That’s all for today my friends , hope you enjoyed the article and learnt something new. Keep learning happy coding , Have a nice day 💖

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jayant Kumar

Jayant Kumar

Hey my name is jayant and i am a youtuber and software Engineer at @Antino