-
Notifications
You must be signed in to change notification settings - Fork 0
koin: What is koin
Devrath edited this page Mar 8, 2024
·
5 revisions
- It involves runtime code generation.
- It uses a service locator design pattern.
- It is built for kotlin.
- It is written in kotlin fully.
- Dependencies are defined in
modules
by grouping related instances. - Modules are created using the
module
function.
- The dependencies are created in 3 ways - This refers to the desired lifecycle behavior.
- Single
- Factory
- Scoped
-
Single
----> This creates a single instance of the desired dependency that is reused through the application lifecycle. -
Factory
---> This creates a new instance of the object every time we request it. -
Scoped
----> This creates a specific instance under aspecific scope
, It can be per activity, fragment, etc.
- Dependencies are injected into the class using
by inject()
delegate that allows us to access the dependencies without instantiating them.
- Koin container holds all the modules in a
container
and provides the required dependencies as needed.