Skip to content

Primitive implementation of dependency injection for kotlin JS.

License

Notifications You must be signed in to change notification settings

sugarp/kotlinjs-di

Repository files navigation

kotlinjs-di

Primitive implementation of dependency injection for kotlin JS.

This is repository of a single file, which happened to be very useful during development of a kotlin multiplatform application for Android and JS + ReactJS. When following MVP I ended up needing Dependency injection similar to Dagger for Java.

You define what is returned when injecting. Because the injection is a function you can either choose whether you create instance:

DI.define<IShape> {
    Circle()
}

or return singleton:

var shape = Circle()

DI.define<IShape> {
    shape
}

and then you inject the defined:

var shape = DI.inject<IShape>()

NOTE: This is designed and developed in time when annotations are not supported for JS and reflection for JS is only in its beginnings.

About

Primitive implementation of dependency injection for kotlin JS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published