This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
require("zone.js"); | |
Zone.__load_patch("generator", (global, Zone, api) => { | |
const generator = function* () {}; | |
const gen = generator(); | |
const Generator = Object.getPrototypeOf(gen); | |
console.log(Generator.next); | |
if (!Generator[Zone.__symbol__("zonePatched")]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @license | |
* Copyright Google Inc. All Rights Reserved. | |
* | |
* Use of this source code is governed by an MIT-style license that can be | |
* found in the LICENSE file at https://angular.io/license | |
*/ | |
(function (factory) { | |
typeof define === 'function' && define.amd ? define(factory) : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let macroTaskCount = 0; | |
let microTaskCount = 0; | |
const zone = Zone.current.fork({ | |
name: 'monitor', | |
onScheduleTask: (delegate, curr, target, task) => { | |
if (task.type === 'macroTask') { | |
macroTaskCount ++; | |
log('new macroTask will be scheduled: ' + macroTaskCount); | |
} else if (task.type === 'microTask') { | |
microTaskCount ++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var originalDelegate = window.setTimeout; | |
window.setTimeout = function(callback, delay) { | |
var zone = Zone.current; | |
var task = { | |
zone: zone, | |
type: 'macroTask', | |
source: 'setTimeout', | |
data: { | |
delay: delay | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var zone = Zone.current.fork({ | |
name: 'hook', | |
onScheduleTask(delegate, current, target, task) { | |
console.log('schedule ZoneTask', task.type, task.source); | |
return delegate.scheduleTask(target, task); | |
}, | |
onInvokeTask(delegate, current, target, task, applyThis, applyArgs) { | |
console.log('invoke ZoneTask', task.type, task.source); | |
return delegate.invokeTask(target, task, applyThis, applyArgs); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function detect() { } | |
const r = detect(); | |
const nativeThen = r.__proto__.then; | |
r.__proto__.then = function () { | |
console.log('promise.then'); | |
return nativeThen.apply(this, arguments); | |
} | |
async function test1() { | |
console.log('before await'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
@Output() highlight = new EventEmitter<string>(); | |
click() { | |
this.highlight.emit('highlight'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var originalDelegate = window.setTimeout; | |
window.setTimeout = function(callback, delay) { | |
var zone = Zone.current; | |
originalDelegate.call(window, function() { | |
zone.run(callback); | |
}, delay); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var zoneA = Zone.current.fork({name: 'zoneA'}); | |
function callback() { | |
// _currentZoneFrame: {zone: zoneA, parent: rootZoneFrame} | |
console.log('callback is invoked in context', Zone.current.name); | |
} | |
// _currentZoneFrame = rootZoneFrame = {zone: root, parent: null} | |
zoneA.run(function() { | |
// _currentZoneFrame: {zone: zoneA, parent: rootZoneFrame} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var currentZoneFrame = {zone: root, parent: null}; | |
class Zone { | |
static get current() { | |
return currentZoneFrame.zone; | |
} | |
run(callback, applyThis, applyArgs) { | |
_currentZoneFrame = {parent: _currentZoneFrame, zone: this}; | |
try { | |
return callback.apply(applyThis, applyArgs); |
NewerOlder