本文整理匯總了TypeScript中@angular/core/src/zone/ng_zone.NgZone.run方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript NgZone.run方法的具體用法?TypeScript NgZone.run怎麽用?TypeScript NgZone.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/core/src/zone/ng_zone.NgZone
的用法示例。
在下文中一共展示了NgZone.run方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: macroTask
macroTask(() => {
_log.add('start run');
_zone.run(() => {
_log.add('nested run');
scheduleMicroTask(_log.fn('nested run microtask'));
});
_log.add('end run');
});
示例2: it
it('should async even if the NgZone was created outside.', async(() => {
// try to escape the current async zone by using NgZone which was created outside.
ngZone.run(() => {
setTimeout(() => {
Promise.resolve('works').then((v) => asyncResult = v);
}, waitLongerThenTestFrameworkAsyncTimeout);
});
}));
示例3: scheduleMicroTask
next: () => {
_log.add('onMicrotaskEmpty(begin)');
if (!donePromiseRan) {
_log.add('onMicrotaskEmpty(schedulePromise)');
_zone.run(() => { scheduleMicroTask(_log.fn('onMicrotaskEmpty(executePromise)')); });
donePromiseRan = true;
}
_log.add('onMicrotaskEmpty(end)');
}
示例4: runNgZoneNoLog
function runNgZoneNoLog(fn: () => any) {
var length = _log.logItems.length;
try {
return _zone.run(fn);
} finally {
// delete anything which may have gotten logged.
_log.logItems.length = length;
}
}
示例5: scheduleMicroTask
ObservableWrapper.subscribe(_zone.onUnstable, (_) => {
_log.add('onUnstable(begin)');
if (!startPromiseRan) {
_log.add('onUnstable(schedulePromise)');
_zone.run(() => { scheduleMicroTask(_log.fn('onUnstable(executePromise)')); });
startPromiseRan = true;
}
_log.add('onUnstable(end)');
});