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
Injector Trees
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kapunahele Wong
July 02, 2019
24
0
Share
Injector Trees
Slides for my talk at the Techmaker Meetup in Reading, UK.
Kapunahele Wong
July 02, 2019
More Decks by Kapunahele Wong
See All by Kapunahele Wong
Contributing to the Angular Docs
kapunahelewong
1
75
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Writing Fast Ruby
sferik
630
63k
So, you think you're a good person
axbom
PRO
2
2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
270
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
RailsConf 2023
tenderlove
30
1.4k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
120
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
540
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Transcript
INJECTOR TREES Kapunahele Wong @kapunahele
angular.io/docs
In the works
None
And on its way…
LOTS. TUTORING @kapunahele @mhevery
IN-DEPTH WITH URI SHAKED & ME ANGULAR CONNECT @UriShaked Photo
credit: Ashnita Bali! @kapunahele
https://github.com/angular/angular/issues
Services @kapunahele
According to the docs: @kapunahele In Angular, a service is
an instance of a class that can be made available to any part of your application using Angular's dependency injection system. From: https://angular.io/start/data
@kapunahele Angular's dependency injection system Stuff in Trees a service
is an instance of a class that can be made available => => =>
Injector trees @kapunahele
ONLY TWO TYPES OF INJECTORS* ▸ModuleInjector ▸ElementInjector @kapunahele
ModuleInjector @kapunahele
MODULEINJECTOR ▸@NgModule.providers ▸@Injectable.providedIn @kapunahele
MODULEINJECTOR ▸@NgModule.providers @kapunahele
MODULEINJECTOR ▸@Injectable.providedIn @kapunahele
MODULEINJECTOR @kapunahele
MODULEINJECTOR @kapunahele
MODULEINJECTOR @kapunahele
ElementInjector @kapunahele
ELEMENTINJECTOR ▸@Component.providers ▸@Component.viewProviders @kapunahele
ELEMENTINJECTOR ▸@Component.providers @kapunahele
ELEMENTINJECTOR ▸@Component.viewProviders @kapunahele
ELEMENTINJECTOR @kapunahele
One is not the parent of the other @kapunahele ModuleInjector
& ElementInjector
ModuleInjector @kapunahele ElementInjector Source: https://svs.gsfc.nasa.gov/11650
ModuleInjector @kapunahele ElementInjector Source: https://svs.gsfc.nasa.gov/11650
ModuleInjector @kapunahele ElementInjector Source: https://svs.gsfc.nasa.gov/11650 1 2
Another analogy @kapunahele
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
Sample apps @kapunahele
MODULEINJECTOR @kapunahele
Our given values: @kapunahele FlowerService: AnimalService:
MODULEINJECTOR @kapunahele
MODULEINJECTOR @kapunahele
ELEMENTINJECTOR @kapunahele
Our given values: @kapunahele FlowerService: AnimalService:
ELEMENTINJECTOR @kapunahele
ELEMENTINJECTOR @kapunahele
So, why two? @Component.providers @Component.viewProviders @kapunahele
@kapunahele
@kapunahele Angular’s logical view representation
@kapunahele <#VIEW> represents an instance of a template and each
component has its own <#VIEW>
@kapunahele Inject the FlowerService: Basic example (ModuleInjector) Add binding in
MyAppComponent template: Renders:
@kapunahele In the logical tree: Basic example (ModuleInjector)
@kapunahele @Component.providers array
@kapunahele @Component.providers
@kapunahele @Component.viewProviders array
@kapunahele @Component.viewProviders
@kapunahele @Component.providers
Visibility decorators @kapunahele
@Host() @kapunahele @SkipSelf() @Self() @Optional()
@Optional() @kapunahele
@Self() @kapunahele
@SkipSelf() @kapunahele
@Host() @kapunahele
@kapunahele The visibility decorators can make different things visible depending
on whether you’ve used @Component.providers or @Component .viewProviders. (Think <#VIEW>)
@kapunahele 1. Two injector trees 2. ElementInjector first, ModuleInjector second
3. Use visibility decorators to customize where the injector starts and stops looking Recap:
https://github.com/kapunahelewong/ element-injector-tree @kapunahele https://github.com/kapunahelewong/ module-injector-tree ElementInjector Demo ModuleInjector Demo Thank
you!!!