本文整理匯總了TypeScript中@angular/core.NgZone.runOutsideAngular方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript NgZone.runOutsideAngular方法的具體用法?TypeScript NgZone.runOutsideAngular怎麽用?TypeScript NgZone.runOutsideAngular使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/core.NgZone
的用法示例。
在下文中一共展示了NgZone.runOutsideAngular方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: applyChanges
private applyChanges(changes: KeyValueChanges<string, Layer>, addFn: (layer: Layer, name: string) => void): LeafletControlLayersChanges {
const results: LeafletControlLayersChanges = new LeafletControlLayersChanges();
if (null != changes) {
// All layer management is outside angular to avoid layer events from triggering change detection
this.zone.runOutsideAngular(() => {
changes.forEachChangedItem((c) => {
this.layersControl.removeLayer(c.previousValue);
addFn.call(this.layersControl, c.currentValue, c.key);
results.layersChanged++;
});
changes.forEachRemovedItem((c) => {
this.layersControl.removeLayer(c.previousValue);
results.layersRemoved++;
});
changes.forEachAddedItem((c) => {
addFn.call(this.layersControl, c.currentValue, c.key);
results.layersAdded++;
});
});
}
return results;
}
示例2: setTimeout
public setTimeout(action: any, timeout?: any): void {
this._ngZone.runOutsideAngular(() => {
window.setTimeout(() => {
action();
}, timeout);
});
}
示例3: updateLayers
/**
* Update the state of the layers.
* We use an iterable differ to synchronize the map layers with the state of the bound layers array.
* This is important because it allows us to react to changes to the contents of the array as well
* as changes to the actual array instance.
*/
private updateLayers() {
const map = this.leafletDirective.getMap();
if (null != map && null != this.layersDiffer) {
const changes = this.layersDiffer.diff(this.layersValue);
if (null != changes) {
// Run outside angular to ensure layer events don't trigger change detection
this.zone.runOutsideAngular(() => {
changes.forEachRemovedItem((c) => {
map.removeLayer(c.item);
});
changes.forEachAddedItem((c) => {
map.addLayer(c.item);
});
});
}
}
}
示例4: macroTask
macroTask(() => {
_zone.runOutsideAngular(
() => { promise = Promise.resolve(4).then((x) => Promise.resolve(x)); });
promise.then(_log.fn('promise then'));
_log.add('zone run');
});
示例5: constructor
constructor(private _platform: Platform, ngZone: NgZone) {
this._change = _platform.isBrowser ? ngZone.runOutsideAngular(() => {
return merge<Event>(fromEvent(window, 'resize'), fromEvent(window, 'orientationchange'));
}) : observableOf();
this._invalidateCache = this.change().subscribe(() => this._updateViewportSize());
}
示例6: ngOnInit
ngOnInit(): void {
if (this.table.settings.hoverEvents) {
this.ngZone.runOutsideAngular(() => {
this.element.addEventListener('mouseover', this.onMouseover.bind(this));
this.element.addEventListener('mouseout', this.onMouseout.bind(this));
});
}
}
示例7: playVideo
playVideo(media: GoogleApiYouTubeVideoResource, seconds?: number) {
const id = media.id;
const isLoaded = this.player.getVideoUrl().includes(id);
if (!isLoaded) {
this.zone.runOutsideAngular(() => this.player.loadVideoById(id, seconds || undefined));
}
this.play();
}
示例8: ngOnInit
ngOnInit(): void {
const editable = this.table.columns.some(x => x.editable);
if (editable) {
this.ngZone.runOutsideAngular(() => {
this.element.addEventListener('dblclick', this.onDblClick.bind(this));
});
}
}
示例9: Error
.then(() => {
if (this.localStorageService.clearAll()) {
this.zone.runOutsideAngular(() => {
location.reload();
});
} else {
throw new Error('Failed to clear local storage');
}
});
示例10: ngAfterViewInit
ngAfterViewInit() {
this._ngZone.runOutsideAngular(() => {
let self: MatchPageComponent = this;
function step() {
self.onFrame();
self.requestAnimationFrameHandle = window.requestAnimationFrame(step);
}
self.requestAnimationFrameHandle = window.requestAnimationFrame(step);
});
}