SlideShare a Scribd company logo
1 of 19
Download to read offline
Zone.js 2017~
@JiaLiPassion
自己紹介
● 名前: 李嘉
● 会社: 利達ソフト
● Zone.js: Collaborator
● Angular: Contributor
● Twitter: @jialipassion
● Github: JiaLiPassion
Agenda
● Zone.js とは
● Angular と Zone.js
● 2017年Zone.js メインのChangelog
● これからZone.jsでやりたいこと
Zone.jsとは
1. Brian Ford さんが2013年DartのZoneのIdeaから作成したライブラリ
a. Provide an execution Context
b. Provide async task lifecycle hook
c. Provide async error handler
Sample Code: Execution Context
Zone.current.fork({
name: 'zone',
properties: {
key: 'value'
}
}).run(() => {
setTimeout(() => {
console.log('in zone', Zone.current.name, Zone.current.get('key')); // will print `in zone zone value
});
})
Sample Code: Lifecycle hook
Zone.current.fork({
name: 'zone',
onScheduleTask: (delegate, curr, target, task) => {
console.log('schedule task', task.source);
return delegate.scheduleTask(target, task);
},
onInvokeTask: (delegate, curr, target, task, applyThis, applyArgs) => {
console.log('before invoke task', task.source);
delegate.invokeTask(target, task, applyThis, applyArgs);
console.log('after invoke task', task.source);
}
}).run(() => {
setTimeout(() => { // 1. onScheduleTask
// 2. onInvokeTask
console.log('timout callback invoked');
});
})
● onScheduleTask
● onInvokeTask
● onCancelTask
● onHasTask
● onHandleError
● onInvoke
● onIntercept
● onFork
Error Handling
Zone.current.fork(
{
name: 'error',
onHandleError: (delegate, curr, target, error) => {
return delegate.handleError(target, error);
}
}).run(() => {
setTimeout(() => {
throw new Error('timeout error');
});
const xhr = new XMLHttpRequest();
xhr.open('get', 'http://notexists', true);
...
xhr.send();
});
Zone Propagation vs Zone Frame
const zoneA = Zone.current.fork({name: 'zoneA'}, onScheduleTask: ...);
const zoneB = Zone.current.fork({name: 'zoneB'}, onScheduleTask: ...);
const zoneC = zoneA.fork({name: 'zoneC', onScheduleTask: ...});
zoneB.run(() => {
// in zoneB
zoneC.run(() => {
// in zoneC
setTimeout(() => {}); // zoneC onScheduleTask => zoneA.onScheduleTask
});
// back in zoneB
});
Implementation: Monkey Patch
const nativeTimeout = window.setTimeout;
window.setTimeout = function(callback) {
const zone = Zone.current;
const wrappedCallback = function() {
zone.onInvokeTask('setTimeout'); // invoke hook
return callback.apply(this, arguments);
}
zone.onScheduleTask('setTimeout'); // schedule hook
nativeTimeout.apply(this, wrappedCallback);
}
Zone.js in Angular
● Change Detection: NgZone
○ onHasTask
○ onInvoke
○ onInvokeTask
● Error Handling
○ onHandleError
● Test
○ SyncTestZoneSpec
○ AsyncTestZoneSpec
○ ProxyZoneSpec
○ LongStackTraceZoneSpec
過去一年のZone.js
1. Performance
2. Better Promise support
3. More API support
4. Better Rxjs Support
5. Better Error handling
6. Module system
7. Closure Build Support
Performance
● GC is the top bottleneck
● Zone.js
○ DOM
■ addEventListener/removeEventListener/onXXX(onClick etc..)
■ BlackListEvent Support (scroll, mousemove…) , __zone_symbol__BLACK_LISTED_EVENTS
○ NodeJS
■ EventEmitter
Reduce objects, especially short live objects. Remove all closures below.
const wrappedCallback = () => {zone.run(eventListener)};
※ Angular DomEvent use more aggressive way to improve performance. It is under testing.
Promise
● Promise A+ Spec Passed
● ZoneAwarePromise load order improvment
○ can load es6/core-js/other 3rdParty promise before/after zone.js without reporting
Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been
overwritten
’
More API support
1. Nw/Electron
2. MediaQuery
3. Notification
4. RTCPeerConnction
5. ShadyDom
6. Cordova
Better Rxjs zone support
// constructor zone.
zoneA.run(() => { observable = new Observable((_subscribe) => subscribe = _subscribe;
console.log('constructing:', Zone.current.name);});});
// operator zone
zoneB.run(() => {observable.map(value => {console.log('mapping:',
Zone.current.name);return value;});});
// subscription zone
zoneC.run(() => {observable.subscribe(value => {console.log('subscription:',
Zone.current.name);});});
// emitter zone
zoneD.run(() => {subscribe.next(1);subscribe.complete();});
Better Error Handling
1. By default, ZoneAware Error will not loaded ( for Chrome Debugger issue)
2. DevMode, import `zone-error` in polyfill.
a. Every stack frame will have zone information
b. Zone.js stack traces will be removed
at eval (app.component.ts:24)
at ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.js:4747)
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:192)
at ZoneTask.invokeTask (zone.js:499)
at ZoneTask.invoke (zone.js:488)
at timer (zone.js:2040)
at eval (app.component.ts:24) [angular]
at Object.onInvokeTask (core.js:4747) [angular]
at timer (zone.js:2040) [<root>]
Module
- Promise
- Timer
- EventTarget
- requestAnimationFrame
- toString
- XHR
- Block
- Geolocation
- ….
- Disable module Sample: __Zone_disable_toString = true
- Flag:
- __Zone_disable_IE_check = true
- __Zone_enable_cross_context_check = true
Closure Build: zone-extern
/**
* @param {string} source
* @param {!Function} callback
* @param {?TaskData=} data
* @param {?function(!Task)=} customSchedule
* @return {!MicroTask} microTask
*/
Zone.prototype.scheduleMicroTask = function(source, callback, data, customSchedule) {};
これからのZone.js
● Fix bugs of Angular NgNoopZone
● Better document
○ Module enable/disable flags
○ Built in ZoneSpec(AsyncTest/SyncTest/Proxy/LongStackTrace/WTF…) usage
○ Tips, such as target[Zone.__symbol__(method)] to access non patched method.
● Unify Dom Event Listener behavior
○ <button (click) = “handler();”></button>
○ btn.addEventListener(‘click’, handler);
○ btn.onclick = handler;
○ <button onclick=”handler();”></button>
● Read only zone implementation with Nodejs asynchooks instead of monkey patch
● Native async/await support with asynchooks + PromiseHook
const p1 = new Promise(() => {}); // This will never be resolved
const p2 = new Promise((resolve) => setTimeout(resolve, 1000, p1)); // resolve p2 with p1 after 1s
● Zone TC39 proposal implementation?
● More API support
○ Electron native API
○ Bluebird

More Related Content

What's hot

如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test名辰 洪
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"OdessaJS Conf
 
NS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIINS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIIAjit Nayak
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in DepthC4Media
 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185Mahmoud Samir Fayed
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyYasuharu Nakano
 
The Ring programming language version 1.5.3 book - Part 72 of 184
The Ring programming language version 1.5.3 book - Part 72 of 184The Ring programming language version 1.5.3 book - Part 72 of 184
The Ring programming language version 1.5.3 book - Part 72 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 45 of 88
The Ring programming language version 1.3 book - Part 45 of 88The Ring programming language version 1.3 book - Part 45 of 88
The Ring programming language version 1.3 book - Part 45 of 88Mahmoud Samir Fayed
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandraKazutaka Tomita
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part IAjit Nayak
 
Understanding the nodejs event loop
Understanding the nodejs event loopUnderstanding the nodejs event loop
Understanding the nodejs event loopSaurabh Kumar
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascriptPavel Volokitin
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt IIAjit Nayak
 
The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.2 book - Part 44 of 84The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.2 book - Part 44 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184Mahmoud Samir Fayed
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJSKyung Yeol Kim
 
Concurrent applications with free monads and stm
Concurrent applications with free monads and stmConcurrent applications with free monads and stm
Concurrent applications with free monads and stmAlexander Granin
 

What's hot (20)

如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 
NS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIINS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt III
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
The Ring programming language version 1.5.3 book - Part 72 of 184
The Ring programming language version 1.5.3 book - Part 72 of 184The Ring programming language version 1.5.3 book - Part 72 of 184
The Ring programming language version 1.5.3 book - Part 72 of 184
 
The Ring programming language version 1.3 book - Part 45 of 88
The Ring programming language version 1.3 book - Part 45 of 88The Ring programming language version 1.3 book - Part 45 of 88
The Ring programming language version 1.3 book - Part 45 of 88
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandra
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
 
Tracing and awk in ns2
Tracing and awk in ns2Tracing and awk in ns2
Tracing and awk in ns2
 
Understanding the nodejs event loop
Understanding the nodejs event loopUnderstanding the nodejs event loop
Understanding the nodejs event loop
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascript
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
 
The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.2 book - Part 44 of 84The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.2 book - Part 44 of 84
 
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
C programs
C programsC programs
C programs
 
Aa
AaAa
Aa
 
Concurrent applications with free monads and stm
Concurrent applications with free monads and stmConcurrent applications with free monads and stm
Concurrent applications with free monads and stm
 

Similar to Zone.js 2017

Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneDroidConTLV
 
Deep Dive into Zone.JS
Deep Dive into Zone.JSDeep Dive into Zone.JS
Deep Dive into Zone.JSIlia Idakiev
 
Real World Lessons on the Pain Points of Node.js Applications
Real World Lessons on the Pain Points of Node.js ApplicationsReal World Lessons on the Pain Points of Node.js Applications
Real World Lessons on the Pain Points of Node.js ApplicationsBen Hall
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineAndy McKay
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構Bo-Yi Wu
 
Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titaniumAxway Appcelerator
 
Node.js flow control
Node.js flow controlNode.js flow control
Node.js flow controlSimon Su
 
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013Gregg Donovan
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationBen Hall
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
Douglas Crockford: Serversideness
Douglas Crockford: ServersidenessDouglas Crockford: Serversideness
Douglas Crockford: ServersidenessWebExpo
 
What is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionWhat is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionIgalia
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVMJohn Lee
 

Similar to Zone.js 2017 (20)

Using zone.js
Using zone.jsUsing zone.js
Using zone.js
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
 
Deep Dive into Zone.JS
Deep Dive into Zone.JSDeep Dive into Zone.JS
Deep Dive into Zone.JS
 
huhu
huhuhuhu
huhu
 
Living with garbage
Living with garbageLiving with garbage
Living with garbage
 
Real World Lessons on the Pain Points of Node.js Applications
Real World Lessons on the Pain Points of Node.js ApplicationsReal World Lessons on the Pain Points of Node.js Applications
Real World Lessons on the Pain Points of Node.js Applications
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構
 
Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titanium
 
Node.js flow control
Node.js flow controlNode.js flow control
Node.js flow control
 
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
 
Living With Garbage
Living With GarbageLiving With Garbage
Living With Garbage
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
Douglas Crockford: Serversideness
Douglas Crockford: ServersidenessDouglas Crockford: Serversideness
Douglas Crockford: Serversideness
 
Why Grails?
Why Grails?Why Grails?
Why Grails?
 
Why Grails
Why GrailsWhy Grails
Why Grails
 
What is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionWhat is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 edition
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVM
 

Recently uploaded

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Recently uploaded (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

Zone.js 2017

  • 2. 自己紹介 ● 名前: 李嘉 ● 会社: 利達ソフト ● Zone.js: Collaborator ● Angular: Contributor ● Twitter: @jialipassion ● Github: JiaLiPassion
  • 3. Agenda ● Zone.js とは ● Angular と Zone.js ● 2017年Zone.js メインのChangelog ● これからZone.jsでやりたいこと
  • 4. Zone.jsとは 1. Brian Ford さんが2013年DartのZoneのIdeaから作成したライブラリ a. Provide an execution Context b. Provide async task lifecycle hook c. Provide async error handler
  • 5. Sample Code: Execution Context Zone.current.fork({ name: 'zone', properties: { key: 'value' } }).run(() => { setTimeout(() => { console.log('in zone', Zone.current.name, Zone.current.get('key')); // will print `in zone zone value }); })
  • 6. Sample Code: Lifecycle hook Zone.current.fork({ name: 'zone', onScheduleTask: (delegate, curr, target, task) => { console.log('schedule task', task.source); return delegate.scheduleTask(target, task); }, onInvokeTask: (delegate, curr, target, task, applyThis, applyArgs) => { console.log('before invoke task', task.source); delegate.invokeTask(target, task, applyThis, applyArgs); console.log('after invoke task', task.source); } }).run(() => { setTimeout(() => { // 1. onScheduleTask // 2. onInvokeTask console.log('timout callback invoked'); }); }) ● onScheduleTask ● onInvokeTask ● onCancelTask ● onHasTask ● onHandleError ● onInvoke ● onIntercept ● onFork
  • 7. Error Handling Zone.current.fork( { name: 'error', onHandleError: (delegate, curr, target, error) => { return delegate.handleError(target, error); } }).run(() => { setTimeout(() => { throw new Error('timeout error'); }); const xhr = new XMLHttpRequest(); xhr.open('get', 'http://notexists', true); ... xhr.send(); });
  • 8. Zone Propagation vs Zone Frame const zoneA = Zone.current.fork({name: 'zoneA'}, onScheduleTask: ...); const zoneB = Zone.current.fork({name: 'zoneB'}, onScheduleTask: ...); const zoneC = zoneA.fork({name: 'zoneC', onScheduleTask: ...}); zoneB.run(() => { // in zoneB zoneC.run(() => { // in zoneC setTimeout(() => {}); // zoneC onScheduleTask => zoneA.onScheduleTask }); // back in zoneB });
  • 9. Implementation: Monkey Patch const nativeTimeout = window.setTimeout; window.setTimeout = function(callback) { const zone = Zone.current; const wrappedCallback = function() { zone.onInvokeTask('setTimeout'); // invoke hook return callback.apply(this, arguments); } zone.onScheduleTask('setTimeout'); // schedule hook nativeTimeout.apply(this, wrappedCallback); }
  • 10. Zone.js in Angular ● Change Detection: NgZone ○ onHasTask ○ onInvoke ○ onInvokeTask ● Error Handling ○ onHandleError ● Test ○ SyncTestZoneSpec ○ AsyncTestZoneSpec ○ ProxyZoneSpec ○ LongStackTraceZoneSpec
  • 11. 過去一年のZone.js 1. Performance 2. Better Promise support 3. More API support 4. Better Rxjs Support 5. Better Error handling 6. Module system 7. Closure Build Support
  • 12. Performance ● GC is the top bottleneck ● Zone.js ○ DOM ■ addEventListener/removeEventListener/onXXX(onClick etc..) ■ BlackListEvent Support (scroll, mousemove…) , __zone_symbol__BLACK_LISTED_EVENTS ○ NodeJS ■ EventEmitter Reduce objects, especially short live objects. Remove all closures below. const wrappedCallback = () => {zone.run(eventListener)}; ※ Angular DomEvent use more aggressive way to improve performance. It is under testing.
  • 13. Promise ● Promise A+ Spec Passed ● ZoneAwarePromise load order improvment ○ can load es6/core-js/other 3rdParty promise before/after zone.js without reporting Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten ’
  • 14. More API support 1. Nw/Electron 2. MediaQuery 3. Notification 4. RTCPeerConnction 5. ShadyDom 6. Cordova
  • 15. Better Rxjs zone support // constructor zone. zoneA.run(() => { observable = new Observable((_subscribe) => subscribe = _subscribe; console.log('constructing:', Zone.current.name);});}); // operator zone zoneB.run(() => {observable.map(value => {console.log('mapping:', Zone.current.name);return value;});}); // subscription zone zoneC.run(() => {observable.subscribe(value => {console.log('subscription:', Zone.current.name);});}); // emitter zone zoneD.run(() => {subscribe.next(1);subscribe.complete();});
  • 16. Better Error Handling 1. By default, ZoneAware Error will not loaded ( for Chrome Debugger issue) 2. DevMode, import `zone-error` in polyfill. a. Every stack frame will have zone information b. Zone.js stack traces will be removed at eval (app.component.ts:24) at ZoneDelegate.invokeTask (zone.js:425) at Object.onInvokeTask (core.js:4747) at ZoneDelegate.invokeTask (zone.js:424) at Zone.runTask (zone.js:192) at ZoneTask.invokeTask (zone.js:499) at ZoneTask.invoke (zone.js:488) at timer (zone.js:2040) at eval (app.component.ts:24) [angular] at Object.onInvokeTask (core.js:4747) [angular] at timer (zone.js:2040) [<root>]
  • 17. Module - Promise - Timer - EventTarget - requestAnimationFrame - toString - XHR - Block - Geolocation - …. - Disable module Sample: __Zone_disable_toString = true - Flag: - __Zone_disable_IE_check = true - __Zone_enable_cross_context_check = true
  • 18. Closure Build: zone-extern /** * @param {string} source * @param {!Function} callback * @param {?TaskData=} data * @param {?function(!Task)=} customSchedule * @return {!MicroTask} microTask */ Zone.prototype.scheduleMicroTask = function(source, callback, data, customSchedule) {};
  • 19. これからのZone.js ● Fix bugs of Angular NgNoopZone ● Better document ○ Module enable/disable flags ○ Built in ZoneSpec(AsyncTest/SyncTest/Proxy/LongStackTrace/WTF…) usage ○ Tips, such as target[Zone.__symbol__(method)] to access non patched method. ● Unify Dom Event Listener behavior ○ <button (click) = “handler();”></button> ○ btn.addEventListener(‘click’, handler); ○ btn.onclick = handler; ○ <button onclick=”handler();”></button> ● Read only zone implementation with Nodejs asynchooks instead of monkey patch ● Native async/await support with asynchooks + PromiseHook const p1 = new Promise(() => {}); // This will never be resolved const p2 = new Promise((resolve) => setTimeout(resolve, 1000, p1)); // resolve p2 with p1 after 1s ● Zone TC39 proposal implementation? ● More API support ○ Electron native API ○ Bluebird