// //

Dagger allows you to bind several objects into a collection even when the objects are bound in different modules using multibindings. Dagger assembles the collection so that application code can inject it without depending directly on the individual bindings.

Dagger允许您将多个对象绑定到一个集合中，即使对象使用多重绑定绑定到不同模块中时也是如此。Dagger组合集合，以便应用程序代码可以注入它而不依赖于单个绑定。

阅读全文
• ## Dagger & Android

### 注入Activity对象

1.Install AndroidInjectionModule in your application component to ensure that all bindings necessary for these base types are available.

1.在您的应用程序组件中安装AndroidInjectionModule以确保这些基本类型所需的所有绑定都可用。

2.Start off by writing a @Subcomponent that implements AndroidInjector, with a @Subcomponent.Builder that extends AndroidInjector.Builder:

2.首先编写一个实现AndroidInjector<YourActivity>@Subcomponent和一个继承AndroidInjector.Builder<YourActivity>@Subcomponent.Builder

阅读全文
• ## Dagger使用指南

### 目录

The best classes in any application are the ones that do stuff: the BarcodeDecoder, the KoopaPhysicsEngine, and the AudioStreamer. These classes have dependencies; perhaps a BarcodeCameraFinder, DefaultPhysicsEngine, and an HttpStreamer.

任何应用程序中最好的类是那些做事情的类：BarcodeDecoderKoopaPhysicsEngineAudioStreamer。 这些类具有依赖性; 也许是一个BarcodeCameraFinderDefaultPhysicsEngine和一个HttpStreamer

To contrast, the worst classes in any application are the ones that take up space without doing much at all: the BarcodeDecoderFactory, the CameraServiceLoader, and the MutableContextWrapper. These classes are the clumsy duct tape that wires the interesting stuff together.