本文整理汇总了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);
});
}