Dagger 2は、 GitHubで説明したように 、依存性注入に対するコンパイル時の進化のアプローチです。 Dagger 1.xのアプローチを究極の結論に導くDagger 2.xは、すべての反射を排除し、従来のObjectGraph
/ Injector
をユーザー指定の@Component
インターフェイスに@Component
コードの明瞭さを向上さ@Component
ます。
Dagger 2はいくつかの特別なアノテーションを公開しています。
メソッドが依存関係を提供するクラスの@Module
@Moduleクラス内のメソッドの@Provides
@Injectで依存関係を要求する(コンストラクタ、フィールド、またはメソッド)
@Componentはモジュールと注入の間のブリッジインターフェースです
GitHub: https : //github.com/google/dagger
UserGuide(Google): https : //google.github.io/dagger/users-guide.html
動画: https : //google.github.io/dagger/resources.html
Vogellaチュートリアル: http ://www.vogella.com/tutorials/Dagger/article.html
Codepathチュートリアル: https : //github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2