Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Dagger2 Optional bindings
Search
funnelbit
November 28, 2016
Technology
610
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Dagger2 Optional bindings
funnelbit
November 28, 2016
More Decks by funnelbit
See All by funnelbit
Hatena Engineer Seminar #9
funnelbit
5
7.5k
droidkaigi-2017-renovation
funnelbit
10
11k
Dart
funnelbit
0
300
BottomBarAndSnackBar
funnelbit
0
540
WearableRecyclerView
funnelbit
1
840
QucikSettingsTileAPI
funnelbit
0
380
Mobile Vision
funnelbit
0
490
AwarenessAPI
funnelbit
0
160
Asynchronous Injection
funnelbit
1
290
Other Decks in Technology
See All in Technology
AIのReact習熟度を測る
uhyo
2
570
中期計画、2回作ってみた ~業務委託と正社員、両方の視点から~
demaecan
1
840
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
2k
Kiroで書いた 設計書 が AI レビューの 採点基準 になる
ezaki
0
110
ルールやカスタム機能、どう活かす?ハンズオンで体感するIBM Bobの出力コントロール
muehara
1
160
RSA暗号を手計算したくなること、ありますよね?? (20260615_orestudy6_rsa)
thousanda
0
430
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
150
データサイエンスを価値につなげるプロジェクト設計 〜 DS一年目が現場で得た気づき 〜
ysd113
1
250
Android の公式 Skill / Android skills
yanzm
0
150
白金鉱業Meetup_Vol.24_「AIエージェントは分けるほど良い」は本当か? / Is it true that “the more you divide AI agents, the better”?
brainpadpr
1
390
入門!AWS Blocks
ysuzuki
1
120
MUSUBI 田中裕一『AIと共に行う「しごとのリデザイン」- スモールバックオフィス編』AI Ops Lab #4
musubi
0
190
Featured
See All Featured
A Soul's Torment
seathinner
6
2.9k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
250
Writing Fast Ruby
sferik
630
63k
Test your architecture with Archunit
thirion
1
2.3k
Navigating Weather and Climate Data
rabernat
0
220
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
970
Designing Powerful Visuals for Engaging Learning
tmiket
1
410
Done Done
chrislema
186
16k
The Pragmatic Product Professional
lauravandoore
37
7.3k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
Transcript
%BHHFS 0QUJPOBMCJOEJOHT
ࣗݾհ ଜྋ גࣜձࣾͯͳ )BUFOBGVOOFMCJU 5XJUUFS!FYQFSPQFSP
w %SPJEP,BJHJʹొஃ͠·͢ w λΠτϧେنΞϓϦͷϦϊϕʔγϣϯ
0QUJPOBMΛఆٛ͠ ޙͰ ղܾͯ͠Β͏ !#JOET0QUJPOBM0G
!#JOET0QUJPOBM0G w 0QUJPOBMCJOEJOHΛ࣮ݱ͢Δػೳ w 0QUJPOBM5Λฦ͢ఆٛΛ༻ҙ͢Δ w ಉ͡ίϯϙʔωϯτ͔ɺαϒίϯϙʔωϯτͰ ΛຬͨͤΔ w %BHHFSd
&OUSZ public class Entry { public final String title; public
Entry(String title) { this.title = title; } }
.PEVMF BCTUSBDU @Module public abstract class MainModule { @BindsOptionalOf public
abstract Entry optionalEntryProvider(); }
$PNQPOFOU @Component(modules = {MainModule.class}) public interface MainComponent { Optional<Entry> entry();
}
.BJO"DUJWJUZ public class MainActivity extends AppCompatActivity { … MainComponent mainComponent
= DaggerMainComponent.create(); Optional<Entry> entry = mainComponent.entry(); Log.e(“entry”, entry.or(new Entry(“default")).title); … } w EFGBVMUͱදࣔ͞ΕΔ
.PEVMF @Module public class EntryModule { @Provides public Entry provideEntry()
{ return new Entry(“entry"); } }
$PNQPOFOU @Component(modules = {MainModule.class, EntryModule.class}) public interface MainComponent { Optional<Entry>
entry(); }
.BJO"DUJWJUZ public class MainActivity extends AppCompatActivity { … Optional<Entry> entry
= mainComponent.entry(); Log.e(“entry”, entry.or(new Entry(“default")).title); … } w FOUSZͱදࣔ͞ΕΔ
$PNQPOFOU ͝ͱʹ ΛมԽͤ͞Δ
&OUSZΛఏڙ͢Δ 4VC$PNQPOFOU &OUSZΛఏڙ͠ͳ͍ 4VC$PNQPOFOU 0QUJPOBMΛ༻ҙ͢Δ $PNQPOFOU 0QUJPOBMΛίϯετϥΫλ Ͱड͚औΔΫϥε "DUJWJUZ 0QUJPOBM5
03
0QUJPOBMΛίϯετϥΫλ Ͱड͚औΔΫϥε public class EntryManager { private final Entry mEntry;
@Inject public EntryManager(Optional<Entry> entryOptional) { mEntry = entryOptional.or(new Entry("default")); } public String getTitle() { return mEntry.title; } }
&OUSZΛఏڙ͠ͳ͍ $PNQPOFOU @Subcomponent public interface EmptyComponent { void inject(MainActivity activity);
@Subcomponent.Builder interface Builder { EmptyComponent build(); } }
&OUSZΛఏڙ͢Δ $PNQPOFOU @Subcomponent(modules = SavedEntryModule.class) public interface SavedEntryComponent { void
inject(MainActivity activity); @Subcomponent.Builder interface Builder { SavedEntryComponent build(); } }
&OUSZΛఏڙ͢Δ $PNQPOFOU @Module public class SavedEntryModule { @Provides Entry provideEntry()
{ return new Entry("saved"); } }
"DUJWJUZ public class MainActivity extends AppCompatActivity { @Inject EntryManager mEntryManager;
… DaggerMainComponent .create() .emptyComponent() .build() .inject(this); Log.e("title", mEntryManager.getTitle()); // default DaggerMainComponent .create() .savedEntryComponent() .build() .inject(this); Log.e("title", mEntryManager.getTitle()); // saved }
·ͱΊ w 0QUJPOBMͷΛޙͰղܾͰ͖Δ w 4VC$PNQPOFOUຖʹࠩҟΛग़ͤΔ w !*OKFDU͕ॻ͔ΕͨϑΟʔϧυɺίϯετϥΫ λͰͦͷ0QUJPOBMΛड͚औΕΔ w $PNQPOFOU͔ΒήολͰऔΔ͜ͱͰ
͖Δ
ࢀߟ w IUUQTHPPHMFHJUIVCJPEBHHFSVTFST HVJEF
͋Γ͕ͱ͏͍͟͝·ͨ͠