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
function forkInnerZoneWithAngularBehavior(zone) { | |
zone._inner = zone._inner.fork({ | |
name: 'angular', | |
properties: { isAngularZone: true }, | |
onInvokeTask: (delegate, current, target, task, applyThis, applyArgs) => { | |
try { | |
onEnter(zone); | |
return delegate.invokeTask(target, task, applyThis, applyArgs); | |
} finally { | |
onLeave(zone); |
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
class NgZone { | |
public run(fn, applyThis, applyArgs) { | |
return this._inner.run(fn, applyThis, applyArgs); | |
} | |
public runOutsideAngular(fn, applyThis, applyArgs) { | |
return this._outer.run(fn, 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
const progress: HTMLElement = document.querySelector('.progress'); | |
let width = 0; | |
const widthInterval = setInterval(() => { | |
width++; | |
progress.style.width = `${width}%`; | |
if (width === 100) { | |
clearInterval(widthInterval); | |
} |
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
const progress: HTMLElement = document.querySelector('.progress'); | |
let width = 0; | |
this.zone.runOutsideAngular(() => { | |
const widthInterval = setInterval(() => { | |
width++; | |
progress.style.width = `${width}%`; | |
if (width === 100) { | |
clearInterval(widthInterval); |
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
function checkStable(zone) { | |
if (zone._nesting == 0 && !zone.hasPendingMicrotasks && !zone.isStable) { | |
try { | |
zone._nesting++; | |
zone.onMicrotaskEmpty.emit(null); | |
} finally { | |
zone._nesting--; | |
if (!zone.hasPendingMicrotasks) { | |
try { | |
zone.runOutsideAngular(() => zone.onStable.emit(null)); |
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
this._zone.onMicrotaskEmpty.subscribe({ | |
next: () => { | |
this._zone.run(() => { | |
this.tick(); | |
}); | |
} | |
}); |
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
class ApplicationRef { | |
tick() { | |
if (this._runningTick) { | |
throw new Error('ApplicationRef.tick is called recursively'); | |
} | |
const scope = ApplicationRef._tickScope(); | |
try { | |
this._runningTick = true; | |
this._views.forEach(view => view.detectChanges()); | |
if (this._enforceNoNewChanges) { |
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
interface Zone { | |
/** | |
* Родительская зона | |
*/ | |
parent: Zone; | |
/** | |
* Название зоны (используется для дебагинга) | |
*/ | |
name: string; | |
/** |
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
dispatch(action) { | |
this.actionsObserver.next(action); | |
} |
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
this.stateSubscription = stateAndAction$.subscribe({ state, action } => { | |
this.next(state); | |
scannedActions.next(action); | |
}); |