ursus
07/16/2020, 4:17 AMgildor
07/16/2020, 4:24 AM@Reusable
?ursus
07/16/2020, 4:30 AMallan.conda
07/16/2020, 4:30 AMursus
07/16/2020, 4:33 AMgildor
07/16/2020, 4:33 AMallan.conda
07/16/2020, 4:34 AMgildor
07/16/2020, 4:34 AMursus
07/16/2020, 4:34 AMgildor
07/16/2020, 4:35 AMursus
07/16/2020, 4:35 AMclass FooModule {
val fooManager by lazy { .. }
}
you can now attach this anywhere, in a daggerless worldgildor
07/16/2020, 4:35 AMursus
07/16/2020, 4:35 AMgildor
07/16/2020, 4:35 AMursus
07/16/2020, 4:39 AMallan.conda
07/16/2020, 4:53 AM@Singleton
ursus
07/16/2020, 4:56 AMgildor
07/16/2020, 5:04 AMwell, yea, so Ill end up with 2 exact same module definitions per app, which is stupid (edited)no, the same module in 2 components
@Singleton
instead of being @Reusable
(it rather important for OkHttp client)allan.conda
07/16/2020, 5:07 AMThere are three rules to follow when installing a module in multiple components:• Providers can only be scoped if all of the components support the same scope annotation. For example, a binding provided in
ViewComponent
and ViewWithFragmentComponent
can be @ViewScoped
because they both support that scope annotation. A binding provided in Fragment
and Service
can not be scoped with any of the standard scopes.
• Providers can only inject bindings if all of the components have access to those bindings. For example, a binding in ViewComponent
and ViewWithFragmentComponent
can inject a View
, whereas something bound in FragmentComponent
and ServiceComponent
could not inject either Fragment
or Service
.
• A child and ancestor component should not install the same module. (Just install the module in the ancestor, and the child will have access to those bindings).ursus
07/16/2020, 4:19 PM