Skip to content

Instantly share code, notes, and snippets.

@digitalbuddha digitalbuddha/holster.kt
Last active Jan 14, 2018

What would you like to do?
//Main Idea: Rather than declaring subcomponents you declare Scopes which contain modules
//Holster is a processor which will generate a subcomponent for each scope and
//allows you to get a reference to each component through a generated Locator.
//Difference with Dagger Android is that we create the child/parent component
//relationship in the scope annotation rather than depending on @ContributesAndroidInjector/HasInjector
@MyActivityScope(ActivityModule::class, child=MyViewScope::class)
class MyActivity{
@inject aDep:ADep
onCreate(){ inject()) }
class MyView{
var Activity.component
get() = Injector.lazyGetComponentFor(this)
var View.component
get() = Injector.lazyGetComponentFor(this)
fun Activity.inject(){
fun View.inject(){
//creates/gets a subcomponent for each instances from a
//generated map of component factories
fun Injector.lazyGetComponentFor(injectRoot:Activity)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.