Skip to content

Instantly share code, notes, and snippets.

View arturovt's full-sized avatar
🎯

Artur arturovt

🎯
View GitHub Profile
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);
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);
}
}
const progress: HTMLElement = document.querySelector('.progress');
let width = 0;
const widthInterval = setInterval(() => {
width++;
progress.style.width = `${width}%`;
if (width === 100) {
clearInterval(widthInterval);
}
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);
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._zone.onMicrotaskEmpty.subscribe({
next: () => {
this._zone.run(() => {
this.tick();
});
}
});
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) {
interface Zone {
/**
* Родительская зона
*/
parent: Zone;
/**
* Название зоны (используется для дебагинга)
*/
name: string;
/**
dispatch(action) {
this.actionsObserver.next(action);
}
this.stateSubscription = stateAndAction$.subscribe({ state, action } => {
this.next(state);
scannedActions.next(action);
});