-
Notifications
You must be signed in to change notification settings - Fork 3
Dependency Injection (EN)
Thanh-Son-Philippe Lam edited this page May 26, 2019
·
1 revision
Dependency Injection for all artifacts (including shared ones) is delegated to each platform. For example, the Android modules makes use of Dagger to inject dependencies.
Nevertheless, the di package of the shared
module contains expected annotations classes that can be used to describe dependencies. For example, here is the Inject
annotation.
@UseExperimental(ExperimentalMultiplatform::class)
@OptionalExpectation
@Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
expect annotation class Inject()
Here is the actual Android implementation.
actual typealias Inject = javax.inject.Inject
The expected dependency injection classes are marked as optional, so that all platforms don't have to provide actual counterparts.