Skip to content

Instantly share code, notes, and snippets.

@EbenezerGH
Last active August 29, 2015 14:07
Show Gist options
  • Save EbenezerGH/b0d00efa49c9f4d8983c to your computer and use it in GitHub Desktop.
Save EbenezerGH/b0d00efa49c9f4d8983c to your computer and use it in GitHub Desktop.
Dagger & Mortar Notes
Mortar & Flow
http://corner.squareup.com/2014/01/mortar-and-flow.html
http://square.github.io/dagger/
Dagger helps you modularize your app into a graph of decoupled components. It takes care of all the wiring and therefore makes it easy to extract dependencies and write single concern objects.
-https://github.com/square/dagger/tree/master/examples/simple/src/main/java/coffee (Coffee Code Example) //Finish going over this
-Builds upon javax.inject annotations(Dependency Injection)
-Dagger Does not support method injection
-Lazy Injection - Lazy<T> deferes instantiation until the first call to Lazy<T>'s get() mehtod. Eachinjection gets its own Lazy<T> unless it is a singleton. Use Lazy Injection for emergencies.
-Static Injection - USE SPARINGLY
-For these cases where @Inject is insufficient or awkward, use an @Provides-annotated method to satisfy a dependency. The method's return type defines which dependency it satisfies.
Mortar provides simple lifecycle callbacks to injected components. Allows for singleton presenters to be saved into a bundle to prevent process death..
https://github.com/square/mortar
Mortar Manages Dagger subgraphs and helps tie them to the activity lifecycle. Effectlively allows us to use the notion of scopes. After a view is finished, garbage collector will do its buisness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment