Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
20241205 DIコンテナ
Search
saka
December 23, 2025
9
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
20241205 DIコンテナ
saka
December 23, 2025
More Decks by saka
See All by saka
20250304 関数型DDD 6
sakatttttta
0
25
20241219 Github Actionsの面倒いところ
sakatttttta
0
18
20250109 関数型
sakatttttta
0
11
20250116 関数型DDD 2
sakatttttta
0
11
20250123 関数型DDD 3
sakatttttta
0
11
20250206 関数型DDD 4
sakatttttta
0
12
20250213 関数型DDD 4
sakatttttta
0
12
20250220 Hono カスタムfetch
sakatttttta
0
10
20250225 関数型DDD 5
sakatttttta
0
9
Featured
See All Featured
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
520
ラッコキーワード サービス紹介資料
rakko
1
5.3M
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
410
Embracing the Ebb and Flow
colly
88
5.2k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Why Our Code Smells
bkeepers
PRO
340
58k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
How to build a perfect <img>
jonoalderson
1
6.1k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
500
Faster Mobile Websites
deanohume
310
32k
Transcript
DIίϯςφ
DIͬͯΔͱ…
new new new
const clientManager = new PrismaClientManager(); const transactionManager = new PrismaTransactionManager(clientManager);
const bookRepository = new PrismaBookRepository(clientManager); const registerBookApplicationService = new RegisterBookApplicationService( bookRepository, transactionManager );
ᓔಃ͍͠
͜͜ͰDIίϯςφ
const clientManager = new PrismaClientManager(); const transactionManager = new PrismaTransactionManager(clientManager);
const bookRepository = new PrismaBookRepository(clientManager); const registerBookApplicationService = new RegisterBookApplicationService( bookRepository, transactionManager ); ͜Ε͕
const registerBookApplicationService = container.resolve( RegisterBookApplicationService ); ͜Μ͚ͩʹ
ղܾํ๏(tsyringe)
Transient ɾσϑΥϧτ ɾresolve ΛݺͿͨͼʹ৽͍͠Πϯελϯε͕࡞ ɾ༻ྫɿී௨ʹ
Singleton ɾΞϓϦέʔγϣϯશମͰ1ͭͷΠϯελϯε ɾ༻ྫɿσʔλϕʔεΫϥΠΞϯτ
ResolutionScoped ɾґଘղܾʢresolveʣͷ1ճͷνΣʔϯͰಉ͡ΠϯελϯεΛ ڞ༗ ɾ༻ɿτϥϯβΫγϣϯͱ͔
ContainerScoped ɾґଘؔίϯςφʔɺ͜ͷґଘؔͷղܾ͕ཁٻ͞ΕΔͨͼ ʹಉ͡ΠϯελϯεΛฦ͠·͢ɻ͜Εγϯάϧτϯʹࣅ͍ͯ· ͕͢ɺࢠίϯςφʔ͕࡞͞ΕΔͱɺͦͷࢠίϯςφʔݻ༗ͷ ΠϯελϯεΛղܾ͠·͢ɻ ɾ༻ɿʁʁʁ
༻ྫ
@injectable() export class RegisterItemApplicationService { constructor( @inject("IItemRepository") private readonly itemRepository:
IItemRepository, @inject("ITransactionManager") private readonly transactionManager: ITransactionManager ) {} ུ }
// TransactionManager container.register("ITransactionManager", { useClass: SimpleTransactionManager, }); // Repository container.register(
"IItemRepository", { useClass: InMemoryItemRepository, }, { lifecycle: Lifecycle.ResolutionScoped, } );
const registerItemApplicationService = container.resolve(RegisterItemApplicationService); await registerItemApplicationService.execute("Notebook");