SlideShare a Scribd company logo
1 of 43
Meetup: AngularJS-Bucharest (25-10-2016)
System
shim
ZoneReflectRx
Libraries
Application
core & common
Angular Frameworks
Router UpgradeHttp Compiler PlatformFormsRouter
<todo-list [source]="todos"
(selected-change)="update($event)" />
System
shim
ZoneReflectRx
Libraries
Application
core & common
Angular Frameworks
Router UpgradeHttp Compiler PlatformFormsRouter
<h1> Hi {{name}} </h1>
<div [property]="value" ></div>
<div (click)="setActive(todo)" ></div>
<input type="text" [(ngModel)]="todo.done">
One-way (Input):
One-way (Output):
Two-way:
DD
D
D
D D
D
D
D
D
D
D
D
<div *ngFor="let todo of todos" >
<input type="checkbox" [(ngModel)]="todo.done" >
<span (click)="setActive(todo)"
[class.done]="todo.done" >
{{todo.text}}
</span>
</div>
@Component({
selector: 'todo-list',
template: `
<div *ngFor="let todo of todos">
<input type="checkbox" [(ngModel)]="todo.done">
<span (click)="setActive(todo)"
[class.done]="todo.done">
{{todo.text}}
</span>
</div>
`})
export class TodoList {
@Output() selectedChange = new EventEmitter()
@Input('source') todos: Todo[] = [];
constructor(private db:Db, private proxy:Proxy){}
}
@Component({
selector: 'todo-list',
template: `
<div *ngFor="let todo of todos">
<input type="checkbox" [(ngModel)]="todo.done">
<span (click)="setActive(todo)"
[class.done]="todo.done">
{{todo.text}}
</span>
</div>
`})
export class TodoList {
@Output() selectedChange = new EventEmitter()
@Input('source') todos: Todo[] = [];
constructor(private db:Db, private proxy:Proxy){}
}
<todo-list [source]="todos"
(selected-change)="update($event)" />
@Injectable()
class Engine {}
@Injectable()
class Car {
constructor( public engine : Engine ) {}
}
var injector = Injector.resolveAndCreate([ Car , Engine ] );
var car = injector.get(Car);
A
Parent Injector
A,B,C
Child Injector
A,B
Child Injector
A
B C
@Injectable()
class A{
constructor(b:B,c:C){ //... }
}
Platform Injectors
Component Injectors
Application Injectors
@Component({
selector: 'todo-list',
providers : [UserProxy],
template: `...`})
export class TodoListComponent { }
@NgModule({
declarations:[AppComponent, ... ],
providers :[UserProxy],
bootstrap :[AppComponent],
imports :[...]
})
export class AppModule{}
platformBrowserDynamic()
.bootstrapModule(AppModule);
FormsModule
exports
(NgModel…)
CommonModule
exports
( NgIf , … )
My Components,
Directives & Pipes
Template Context@NgModule({
declarations:[...],
imports :[...],
exports :[...],
bootstrap :[...]
})
export class XxxModule{}
@NgModule({
declarations:[...],
imports :[...],
exports :[...],
})
export class XxxModule{}
@NgModule({
declarations:[...],
imports :[...]
})
export class XxxModule{}
@NgModule({
declarations:[...]
})
export class XxxModule{}
@NgModule({
})
export class XxxModule{}
Application Injector
XxxModule
providers
RouterModule
providers
Lazy Loading
Boundary
Module Injector
MathModule
providers
UsersModule
providers
@NgModule({
declarations:[...],
imports :[...],
exports :[...],
bootstrap :[...],
providers :[...]
})
export class XxxModule{}
@NgModule({
declarations:[...],
imports :[...],
exports :[...],
bootstrap :[...],
providers :[...]
})
export class XxxModule{}
@NgModule({
declarations:[...],
imports :[...],
exports :[...],
bootstrap :[...],
providers :[...]
})
export class XxxModule{}
Platform
Injector
Lazy Loading
Boundary
App Module
Core
Module
Feature I
Module
Feature II
Module
Feature III
Module
Shared
Module
Shared
Module
Lazy Loading
Boundary
App Module
Core
Module
Feature I
Module
Feature II
Module
Feature III
Module
Shared
Module
Shared
Module
Lazy Loading
Boundary
App Module
Core
Module
Feature I
Module
Feature II
Module
Feature III
Module
Shared
Module
Shared
Module
@NgModule({
imports: [...],
declarations: [...],
exports: [...],
providers: [...]
})
export class CoreModule {
constructor (@Optional() @SkipSelf() parentModule: CoreModule) {
if (parentModule) {
throw new Error('CoreModule is already loaded.');
}
}
static forRoot(config: UserServiceConfig): ModuleWithProviders {
return {
ngModule: CoreModule,
providers: [
{provide: UserServiceConfig, useValue: config }
]
};
}
}
Prevent
reimport
Configure
core services
UI
(DOM)
Model
<div *ngFor="#todo of todos">
<input [(ngModel)]="todo.done">
<span (click)="setActive(todo)"
[class.done]="todo.done">
{{todo.text}}
</span>
</div>
Component
(7 expressions)
Component
(5 expressions)
Component
(9 expressions)
Component
(6 expressions)
Component
(2 expressions)
Component
(3 expressions)
 {{interpolation}}
 [property] = "exp"
Timer Event
(50ms)
Communication (300ms)
UI Events
(avg 3s)
UI Events
(avg 2s)
Component
(7 expressions)
Component
(5 expressions)
Component
(9 expressions)
Component
(6 expressions)
Component
(2 expressions)
Component
(3 expressions)
export class CounterComponent {
value:number = 0;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
setInterval( ()=>{ this.value++; } , 50 );
}
}
Ticks
Never use
setInterval method
setInterval( ()=>{ this.value++; } , 50 );
Update
export class CounterComponent {
value:number = 0;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
run();
}
run(){
this.value++;
setTimeout( ()=> { this.run() } , 50 );
}
}
Create method
every time
Ticks Update
setTimeout( ()=> { this.run() } , 50 );
export class CounterComponent {
value : number = 0;
runFnBind : any;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
this.runFnBind = this.run.bind(this);
run();
}
run(){
this.value++;
setTimeout( this.runFnBind , 50 );
}
}
Ticks Update
this.runFnBind = this.run.bind(this);
setTimeout( this.runFnBind , 50 );
export class CounterComponent {
value : number = 0;
runFnBind : any;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
this.runFnBind = this.run.bind(this);
zone.runOutsideAngular( this.runFnBind );
}
run(){
this.value++;
setTimeout( this.runFnBind , 50 );
}
}
Ticks Update
zone.runOutsideAngular( this.runFnBind );
export class CounterComponent {
value:number = 0;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
zone.runOutsideAngular( this.run.bind(this) );
}
run(){
this.value++;
this.cd.detectChanges();
setTimeout( this.run.bind(this) , 50 );
}
}
Ticks Update
this.cd.detectChanges();
Search
Title : {{title}}
Name : {{name}}
Phone : {{phone}}
Mobile : {{mobile}}
Picture: {{picture}}
export class MonitorComponent {
...
constructor(private cd :ChangeDetectorRef){
cd.detach();
}
...
set serverLoadValue(val){
let isthreshold = this.checkThreshold(val);
this._serverLoadValue = val;
if(isthreshold){
this.cd.detectChanges();
}
}
}
cd.detach();
this.cd.detectChanges();
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)

More Related Content

What's hot

What's hot (20)

Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
 
Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injection
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
 
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xUpgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
 
AngularJS Internal
AngularJS InternalAngularJS Internal
AngularJS Internal
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
 
AngularJS $Provide Service
AngularJS $Provide ServiceAngularJS $Provide Service
AngularJS $Provide Service
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 Views
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
 
AngularJs
AngularJsAngularJs
AngularJs
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 

Similar to Angular 2 Architecture (Bucharest 26/10/2016)

What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
Alfonso Fernández
 
Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8
Ovadiah Myrgorod
 

Similar to Angular 2 Architecture (Bucharest 26/10/2016) (20)

Angular 2 Architecture
Angular 2 ArchitectureAngular 2 Architecture
Angular 2 Architecture
 
What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Backbone js
Backbone jsBackbone js
Backbone js
 
How to Mess Up Your Angular UI Components
How to Mess Up Your Angular UI ComponentsHow to Mess Up Your Angular UI Components
How to Mess Up Your Angular UI Components
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Aurelia Meetup Paris
Aurelia Meetup ParisAurelia Meetup Paris
Aurelia Meetup Paris
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
The MEAN stack
The MEAN stack The MEAN stack
The MEAN stack
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builder
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Backbone js-slides
Backbone js-slidesBackbone js-slides
Backbone js-slides
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11
 
Django quickstart
Django quickstartDjango quickstart
Django quickstart
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"
 
Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8
 
Web Components With Rails
Web Components With RailsWeb Components With Rails
Web Components With Rails
 
Gutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisablesGutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisables
 
"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović
 

More from Eyal Vardi (15)

Why magic
Why magicWhy magic
Why magic
 
Smart Contract
Smart ContractSmart Contract
Smart Contract
 
Rachel's grandmother's recipes
Rachel's grandmother's recipesRachel's grandmother's recipes
Rachel's grandmother's recipes
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
 
Async & Parallel in JavaScript
Async & Parallel in JavaScriptAsync & Parallel in JavaScript
Async & Parallel in JavaScript
 
Angular 2.0 Pipes
Angular 2.0 PipesAngular 2.0 Pipes
Angular 2.0 Pipes
 
Modules in ECMAScript 6.0
Modules in ECMAScript 6.0Modules in ECMAScript 6.0
Modules in ECMAScript 6.0
 
Proxies in ECMAScript 6.0
Proxies in ECMAScript 6.0Proxies in ECMAScript 6.0
Proxies in ECMAScript 6.0
 
Iterators & Generators in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0Iterators & Generators in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0
 
Symbols in ECMAScript 6.0
Symbols in ECMAScript 6.0Symbols in ECMAScript 6.0
Symbols in ECMAScript 6.0
 
Objects & Classes in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0Objects & Classes in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0
 
Scope & Functions in ECMAScript 6.0
Scope & Functions in ECMAScript 6.0Scope & Functions in ECMAScript 6.0
Scope & Functions in ECMAScript 6.0
 
Node.js Spplication Scaling
Node.js Spplication ScalingNode.js Spplication Scaling
Node.js Spplication Scaling
 
Node.js Socket.IO
Node.js  Socket.IONode.js  Socket.IO
Node.js Socket.IO
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

Angular 2 Architecture (Bucharest 26/10/2016)

Editor's Notes

  1. Angular 2 will scan the entire tree component and calculate each expression every 50ms.