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 AMgildor
07/16/2020, 4:34 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 AMgildor
07/16/2020, 4:35 AMgildor
07/16/2020, 4:35 AMgildor
07/16/2020, 4:36 AMgildor
07/16/2020, 4:36 AMgildor
07/16/2020, 4:36 AMursus
07/16/2020, 4:39 AMursus
07/16/2020, 4:47 AMursus
07/16/2020, 4:53 AMallan.conda
07/16/2020, 4:53 AM@Singletonursus
07/16/2020, 4:56 AMursus
07/16/2020, 4:57 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
gildor
07/16/2020, 5:05 AMgildor
07/16/2020, 5:05 AM@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).allan.conda
07/16/2020, 5:10 AMursus
07/16/2020, 4:19 PMursus
07/16/2020, 4:21 PM