本文整理汇总了TypeScript中angular2/src/core/zone/ng_zone.NgZone.run方法的典型用法代码示例。如果您正苦于以下问题:TypeScript NgZone.run方法的具体用法?TypeScript NgZone.run怎么用?TypeScript NgZone.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/core/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: 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;
}
}
示例3: scheduleMicroTask
ObservableWrapper.subscribe(_zone.onMicrotaskEmpty, (_) => {
_log.add('onMicrotaskEmpty(begin)');
if (!donePromiseRan) {
_log.add('onMicrotaskEmpty(schedulePromise)');
_zone.run(() => { scheduleMicroTask(_log.fn('onMicrotaskEmpty(executePromise)')); });
donePromiseRan = true;
}
_log.add('onMicrotaskEmpty(end)');
});
示例4: macroTask
macroTask(() => {
var exception = new BaseException('sync');
_zone.run(() => { throw exception; });
expect(_errors.length).toBe(1);
expect(_errors[0]).toBe(exception);
async.done();
});
示例5:
ObservableWrapper.subscribe(_zone.onMicrotaskEmpty, (_) => {
_log.add('onMicrotaskEmpty:started');
_zone.run(() => _log.add('nested run'));
_log.add('onMicrotaskEmpty:finished');
});