Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Angular‘s Future with Ivy @ngPoland 2020
Manfred Steyer
PRO
November 19, 2020
Programming
0
120
Angular‘s Future with Ivy @ngPoland 2020
Manfred Steyer
PRO
November 19, 2020
Tweet
Share
More Decks by Manfred Steyer
See All by Manfred Steyer
manfredsteyer
PRO
0
89
manfredsteyer
PRO
0
84
manfredsteyer
PRO
0
190
manfredsteyer
PRO
0
140
manfredsteyer
PRO
0
120
manfredsteyer
PRO
0
240
manfredsteyer
PRO
0
200
manfredsteyer
PRO
0
310
manfredsteyer
PRO
0
360
Other Decks in Programming
See All in Programming
deepflow
4
1.4k
ryokbt
2
280
madai0517
1
160
ntaro
0
160
mrtc0
2
930
emmaglorypraise
0
120
morimorihoge
1
150
ryosukes
0
1.3k
christianweyer
PRO
0
270
nearmugi
0
170
takara9
0
150
mihyaeru21
0
360
Featured
See All Featured
kneath
219
15k
erikaheidi
14
4.3k
jakevdp
774
200k
moore
125
21k
aarron
257
36k
kneath
295
39k
wjessup
339
16k
malarkey
119
16k
bkeepers
52
4.2k
chriscoyier
684
180k
shpigford
165
19k
dougneiner
119
7.9k
Transcript
@ManfredSteyer ManfredSteyer Manfred Steyer, ANGULARarchitects.io Angular‘s Future with Ivy: Outlooks
and Prophecies
@ManfredSteyer Ivy Compiler Leads to Smaller Bundles Up to 40%
less bundle size!
@ManfredSteyer
@ManfredSteyer DEMO
@ManfredSteyer
@ManfredSteyer Contents Lazy Components Dynamic Components Higher Order Components Standalone
Components Zone-less Angular
@ManfredSteyer Manfred Steyer
@ManfredSteyer
@ManfredSteyer Lazy Load an Ivy Component import('../dashboard-tile/dashboard-tile.component').then(m => { […]
}
@ManfredSteyer Lazy Load an Ivy Component import('../dashboard-tile/dashboard-tile.component').then(m => { const
comp = m.DashboardTileComponent; […] }
@ManfredSteyer Lazy Load an Ivy Component import('../dashboard-tile/dashboard-tile.component').then(m => { const
comp = m.DashboardTileComponent; const factory = this.cfr.resolveComponentFactory(comp); […] } ComponentFactoryResolver (Injected)
@ManfredSteyer Lazy Load an Ivy Component import('../dashboard-tile/dashboard-tile.component').then(m => { const
comp = m.DashboardTileComponent; const factory = this.cfr.resolveComponentFactory(comp); const compRef = this.viewContainer.createComponent( factory, null, this.injector); } Get via @ViewChild(…)
@ManfredSteyer DEMO
@ManfredSteyer
@ManfredSteyer Why Does This Work with Ivy? With Ivy, the
component is self-describing Remember: Component.ɵcmp Principle: Locality Before Ivy: Metadata within NgModules
@ManfredSteyer Potential Lazy Loading ;-) Partial Hydration
@ManfredSteyer Don't use them in production! No guarantees these features
will ever land in Angular!
@ManfredSteyer
@ManfredSteyer Dynamic Component export function create() { […] }
@ManfredSteyer Dynamic Component export function create() { class DynamicComponent implements
OnInit { […] } […] }
@ManfredSteyer Dynamic Component export function create() { class DynamicComponent implements
OnInit { […] } […] DynamicComponent.ɵcmp = […]; […] }
@ManfredSteyer Dynamic Component export function create() { class DynamicComponent implements
OnInit { […] } […] DynamicComponent.ɵcmp = […]; return DynamicComponent; }
@ManfredSteyer Higher-Order Component export function create(otherComponent: Type<any>) { class DynamicComponent
implements OnInit { […] } […] DynamicComponent.ɵcmp = […]; return DynamicComponent; }
@ManfredSteyer Higher-Order Component export function create(otherComponent: Type<any>) { class DynamicComponent
implements OnInit { […] } […] DynamicComponent.ɵcmp = […]; return DynamicComponent; } Call otherComponent in template function
@ManfredSteyer DEMO
@ManfredSteyer Potential More dynamic Framework extensions
@ManfredSteyer
@ManfredSteyer Composing Components DashboardTileComponent 3x BarComponent
@ManfredSteyer Defining a Component's "Neighborhood" DashboardTileComponent.ɵcmp
@ManfredSteyer Defining a Component's "Neighborhood" DashboardTileComponent.ɵcmp.directiveDefs = [ […] ];
@ManfredSteyer Defining a Component's "Neighborhood" DashboardTileComponent.ɵcmp.directiveDefs = [ BarComponent.ɵcmp ];
Type Assertions ("type casts") not shown here …
@ManfredSteyer Grouping Components import { BarComponent } from "./bar.component"; export
const BAR_COMPONENTS = [ BarComponent, […] ]; index.ts
@ManfredSteyer @Component({ […], deps: [ ...BAR_COMPONENTS ] }) export class
DashboardTileComponent { […] } Proposal
@ManfredSteyer DEMO
@ManfredSteyer
@ManfredSteyer Bootstrapping platformBrowserDynamic().bootstrapModule(AppModule);
@ManfredSteyer Bootstrapping ɵrenderComponent(MyAngularComponent);
@ManfredSteyer Potential Project Structure: Libs and/or Barrels (index.ts) Standalone Components
-> Web Components
@ManfredSteyer
@ManfredSteyer What is Zone.js? Key to automatic change detection Monkey-patches
all browser objects
@ManfredSteyer Downsides 100+ KB (uncompressed): Web Components? Money Patching: Magic
Cannot monkey patch native async/ await (ES 2017)
@ManfredSteyer Mark Components as Dirty import { ɵmarkDirty } from
'@angular/core'; […] ɵmarkDirty(this /* <-- Component */);
@ManfredSteyer DEMO
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer Conclusion Fine grained lazy loading --> Partial hydration Dynamic
and higher order components --> Framework extensions Standalone components --> Structure with barrels and libs Zone-less: Future-proof General: More lightweight
@ManfredSteyer "Your future hasn't been written yet!" Emmet Brown, PhD
@ManfredSteyer d Slides & Examples Public: Frankfurt, Munich, Vienna In-House:
everywhere