Created
August 13, 2017 08:41
-
-
Save guliash/e4fe849c7923feeecd9746853517a1d5 to your computer and use it in GitHub Desktop.
Reusable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component(modules = MyModule.class) | |
public interface ComponentA { | |
OkHttpClient a(); | |
SubcomponentB subcomponentB(); | |
SubcomponentC subcomponentC(); | |
} | |
@Module | |
public class MyModule { | |
@Reusable | |
@Provides | |
public OkHttpClient a() { | |
return new OkHttpClient(); | |
} | |
} | |
@Subcomponent | |
public interface SubcomponentB { | |
OkHttpClient a(); | |
} | |
@Subcomponent | |
public interface SubcomponentC { | |
OkHttpClient a(); | |
} | |
public class OkHttpClient { | |
public OkHttpClient() { | |
} | |
} | |
public class Main { | |
public static void main(String[] args) { | |
ComponentA componentA = DaggerComponentA.create(); | |
System.out.println(componentA.subcomponentB().a()); | |
System.out.println(componentA.subcomponentC().a()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment