Reputation: 62549
What is the 'include' word used for in dagger. For example from the docs here is a module defined like this:
@Module(
includes = {
DripCoffeeModule.class,
ExecutorModule.class
}
)
public class CoffeeAppModule {
}
Notice how this module which is an app module includes the other modules in it ? why ? what is the usefulness. You can check for the example here
I dont understand the includes keyword in the module annotation, what is it used for ?
from the javadocs its described with the following definition still leaving me confused , can someone provide an example:
includes Additional @Module-annotated classes from which this module is composed.
update: what im thinking include means is that if i have providers in other modules say in module1.java then if i 'include' module1.java in module2.java it can see all the provider methods in it and the scope of module2 has now increased, is this correct ?
Upvotes: 0
Views: 424
Reputation: 62549
I think i get it now. Include is just like 'include' in C headers or include in android's xml files when you want to include an external viewgroup etc. It just means your including the module methods themselves in the file. ITs just a way to split out code to be organized. So 'addsto' adds it to the graph of the module you specify but 'includes' just copies the code from that module into the file.
Upvotes: 0
Reputation: 2890
It's used for splitting your Graph into multiple Modules. So you create your ObjectGraph with your "Root"-Module which includes possibly multiple Modules (which then can include Modules again). This way you split your Modules into logical groups.
Upvotes: 1