Skip to content

Instantly share code, notes, and snippets.

@catalinghita8
Last active August 6, 2020 15:18
Show Gist options
  • Select an option

  • Save catalinghita8/3bd59f9d93325fb4a429f26b23d9e10a to your computer and use it in GitHub Desktop.

Select an option

Save catalinghita8/3bd59f9d93325fb4a429f26b23d9e10a to your computer and use it in GitHub Desktop.
// Container of objects shared across the whole project
class DependencyInjector {
private val objectA: A = A()
private val objectB: B = B()
val repository: Repository = Repository(objectA, objectB)
}
fun main {
val injectedRepository = DependencyInjector.repository
val vm = ViewModel(injectedRepository)
vm.doSomething()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment