Skip to content

Commit aae8de1

Browse files
committed
Add user docs for @Module.subcomponents
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=132470435
1 parent 71a7973 commit aae8de1

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

core/src/main/java/dagger/Component.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,13 @@
171171
* inherit the <em>entire</em> binding graph from its parent when it is declared. For that reason,
172172
* a subcomponent isn't evaluated for completeness until it is associated with a parent.
173173
*
174-
* <p>Subcomponents are declared via a factory method on a parent component or subcomponent. The
175-
* method may have any name, but must return the subcomponent. The factory method's parameters may
176-
* be any number of the subcomponent's modules, but must at least include those without visible
174+
* <p>Subcomponents are declared by listing the class in the {@link Module#subcomponents()}
175+
* attribute of one of the parent component's modules. This binds the {@link Subcomponent.Builder}
176+
* within the parent component.
177+
*
178+
* <p>Subcomponents may also be declared via a factory method on a parent component or subcomponent.
179+
* The method may have any name, but must return the subcomponent. The factory method's parameters
180+
* may be any number of the subcomponent's modules, but must at least include those without visible
177181
* no-arg constructors. The following is an example of a factory method that creates a
178182
* request-scoped subcomponent from a singleton-scoped parent: <pre><code>
179183
* {@literal @}Singleton {@literal @}Component

core/src/main/java/dagger/Module.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
* Any {@link Subcomponent}- or {@code @ProductionSubcomponent}-annotated classes which should be
4141
* children of the component in which this module is installed. A subcomponent may be listed in
4242
* more than one module in a component.
43+
*
44+
* @since 2.7
4345
*/
4446
@Beta
4547
Class<?>[] subcomponents() default {};

producers/src/main/java/dagger/producers/ProducerModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
* Any {@link dagger.Subcomponent}- or {@link ProductionSubcomponent}-annotated classes which
4747
* should be children of the component in which this module is installed. A subcomponent may be
4848
* listed in more than one module in a component.
49+
*
50+
* @since 2.7
4951
*/
5052
Class<?>[] subcomponents() default {};
5153
}

0 commit comments

Comments
 (0)