Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Understanding Dagger2 Part1

Avatar for FujiKinaga FujiKinaga
November 20, 2018

Understanding Dagger2 Part1

Avatar for FujiKinaga

FujiKinaga

November 20, 2018
Tweet

More Decks by FujiKinaga

Other Decks in Programming

Transcript

  1. What’s Dagger2, why use it? • DI (Dependency Injection) Library

    • Easy to test • Manage Lifecycle • Module sharing, reusing, replacing • Auto code generating with annotation • Ikeike, Cool, Kacchoiiiiiiiiiii
  2. Constitution • @Inject
 - ϑΟʔϧυσʔλ΍ίϯετϥΫλʹ෇͚Δͱର৅ΦϒδΣΫτΛnew͠ͳͯ͘ ΋injectΛݺΜͩλΠϛϯάͰউखʹ࡞ͬͯ͘ΕΔ • Module
 - new

    ͍ͨ͠΋ͷΛఆ͓ٛͯ͘͠ͱ͜Ζ • Component
 - ֤Moduleಉ࢜ΛͲͷΑ͏ʹඥ෇͚(ґଘ)ͤ͞Δ͔Λఆٛ͢Δ΋ͷ
 - Moduleಉ͕࢜਌ࢠؔ܎ͱͳΓɺࢠ͸਌ͷModule΋ࢀরͰ͖Δ • Scope
 - ComponentΛͲΕ͘Β͍ͷؒੜଘͤ͞Δ͔Λ؅ཧ͢Δ΋ͷ
  3. References • Dagger2 ೖ໳ղઆ
 - https://qiita.com/MoyuruAizawa/items/ 26cb093adbc778013467 • Dependency Injection

    with Dagger2
 - https://jakewharton.com/dependency-injection-with-dagger-2/ • Dagger Android֦ுͷ࢖͍ํ
 - https://medium.com/@star_zero/dagger- android%E6%8B%A1%E5%BC%B5%E3%81%AE%E4%BD%BF %E3%81%84%E6%96%B9-6527dcb74531
  4. Next Steps • Helping Dagger Help You
 - https://jakewharton.com/helping-dagger-help-you/ •

    Dagger2 - Subcomponent vs dependencies
 - http://yuki312.blogspot.com/2016/02/android- dagger2-subcomponent-vs.html • Dagger2 - MultibindingͰComponentΛ៉ྷʹ࢓্͛Δ
 - http://yuki312.blogspot.com/2017/02/dagger2- multibindingcomponent.html