We'll discuss recent developments in Dagger for Android, both in terms of new APIs in dagger.android and optimizations in generated code. We'll then discuss how to not encounter common pitfalls that decrease runtime performance.
key? ◦ 0 ! missing binding error ◦ 2+ ! duplicate binding error • How can Binding X be represented as DependencyRequest.Kind Y using X's own dependencies? java/dagger/internal/codegen/BindingExpression.java
Wing leftWing, @Right Wing rightWing, Welder welder) {}1 }2 Life of a DependencyRequest java/dagger/internal/codegen/SimpleMethodBindingExpression.java
=15 6new Provider<Welder>() { @Override public Welder get()3{ return new Welder( new Wire(), new ProtectiveShield(), flamethrowerProvider.get()); }4 }; }2 java/dagger/internal/codegen/FrameworkFieldInitializer.java
=1DoubleCheck.provider(5 6new Provider<Welder>() { @Override public Welder get()3{ return new Welder( new Wire(), new ProtectiveShield(), flamethrowerProvider.get()); }4 }); }2 java/dagger/internal/codegen/FrameworkFieldInitializer.java
=1DoubleCheck.provider(5 6new Provider<Welder>() { ^ error: [MemoryLeak] this might leak your *entire* component! @Override public Welder get()3{ return new Welder( new Wire(), new ProtectiveShield(), flamethrowerProvider.get()); }4 }); }2 java/dagger/internal/codegen/FrameworkFieldInitializer.java ^ shameless plug for ErrorProne github.com/google/error-prone
Lazy<YourBinding> And || you always call get() exactly once (especially in the constructor / onCreate()) || YourBinding is not expensive to create, but you aren't sure if you need it
Lazy<YourBinding> And || you always call get() exactly once (especially in the constructor / onCreate()) || YourBinding is not expensive to create, but you aren't sure if you need it
Lazy<YourBinding> And || you always call get() exactly once (especially in the constructor / onCreate()) || YourBinding is not expensive to create, but you aren't sure if you need it Instead
Lazy<YourBinding> And || you always call get() exactly once (especially in the constructor / onCreate()) || YourBinding is not expensive to create, but you aren't sure if you need it Instead && Simply inject YourBinding with no wrapper type
Lazy<YourBinding> And || you always call get() exactly once (especially in the constructor / onCreate()) || YourBinding is not expensive to create, but you aren't sure if you need it Instead && Simply inject YourBinding with no wrapper type && Profile your code!
hammer, everything looks like a @Subcomponent ◦ but subcomponents require compilation at the root! • Break up compilation where possible ◦ gradle users: make lots of modules ◦ bazel users: split up java_librarys