Winter

Kotlin Dependency Injection

License

License

GroupId

GroupId

io.jentz.winter
ArtifactId

ArtifactId

winter
Last Version

Last Version

0.9.0
Release Date

Release Date

Type

Type

jar
Description

Description

Winter
Kotlin Dependency Injection
Project URL

Project URL

https://github.com/beyama/winter
Source Code Management

Source Code Management

https://github.com/beyama/winter

Download winter

How to add to project

<!-- https://jarcasting.com/artifacts/io.jentz.winter/winter/ -->
<dependency>
    <groupId>io.jentz.winter</groupId>
    <artifactId>winter</artifactId>
    <version>0.9.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.jentz.winter/winter/
implementation 'io.jentz.winter:winter:0.9.0'
// https://jarcasting.com/artifacts/io.jentz.winter/winter/
implementation ("io.jentz.winter:winter:0.9.0")
'io.jentz.winter:winter:jar:0.9.0'
<dependency org="io.jentz.winter" name="winter" rev="0.9.0">
  <artifact name="winter" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.jentz.winter', module='winter', version='0.9.0')
)
libraryDependencies += "io.jentz.winter" % "winter" % "0.9.0"
[io.jentz.winter/winter "0.9.0"]

Dependencies

compile (1)

Group / Artifact Type Version
javax.inject : javax.inject jar 1

runtime (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.3.70

test (5)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.5.1
io.kotlintest : kotlintest-assertions jar 3.4.0
org.jetbrains.kotlin : kotlin-reflect jar 1.3.70
org.mockito : mockito-core jar 3.0.0
com.nhaarman.mockitokotlin2 : mockito-kotlin jar 2.1.0

Project Modules

There are no modules declared in this project.

Winter

Kotlin 1.3.40 Maven Central Travis MIT License GitHub issues

Kotlin Dependency Injection

Winter is a fast and intuitive dependency injection library for Kotlin on Android and the JVM.

It offers an idiomatic Kotlin API as well as optional JSR-330 support with annotation processor.

Winter documentation

Installation

dependencies {
  // Core
  implementation 'io.jentz.winter:winter:0.7.0'
  // AndroidX support
  implementation 'io.jentz.winter:winter-androidx:0.7.0'
  // RxJava 2 disposable plugin
  implementation 'io.jentz.winter:winter-rxjava2:0.7.0'
  // Java support
  implementation 'io.jentz.winter:winter-java:0.7.0'
  // JUnit 4 test support
  testImplementation 'io.jentz.winter:winter-junit4:0.7.0'  
  // JUnit 5 test support
  testImplementation 'io.jentz.winter:winter-junit5:0.7.0'  
  // Optional JSR-330 support
  kapt 'io.jentz.winter:winter-compiler:0.7.0'
}

Quickstart Android

Given is an Android application with an application component, a presentation subcomponent that survives orientation changes and an activity subcomponent.

class MyApplication : Application() {
  override fun onCreate() {
    // define application component
    Winter.component(ApplicationScope::class) {
      singleton<HttpClient> { HttpClientImpl() }
      singleton<GitHubApi> { GitHubApiImpl(instance()) }
      
        // define presentation subcomponent
        subcomponent(PresentationScope::class) {
          singleton<ReposListViewModel> { RepolistViewModel(instance<GitHubApi>()) }
          
          // define activity subcomponent
          subcomponent(ActivityScope::class) {
            singleton { Glide.with(instance()) }
          }
        }
    }

    // Configure the injection adapter to use   
    Winter.useAndroidPresentationScopeAdapter()
    // Create application dependency graph
    Winter.inject(this)
  }
}

class MyActivity : Activity() {
  private val viewModel: RepoListViewModel by inject()
  private val glide: RequestManager by inject()

  override fun onCreate(savedInstanceState: Bundle?) {
    Winter.inject(this)
    super.onCreate(savedInstanceState)
  }

}

Read more

Winter is used in production since end of 2017. The API is considered mostly stable but there will be no guarantee before version 1.x.

Winter supports only Android and JVM right now but support for native (iOS) and JavaScript is planed.

Winter documentation

License

Copyright 2017 Alexander Jentz

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
0.9.0
0.8.0
0.7.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.1
0.3.0
0.2.0
0.1.0
0.0.4
0.0.3
0.0.2
0.0.1