本文整理汇总了TypeScript中angular2/src/core/zone/ng_zone.NgZone类的典型用法代码示例。如果您正苦于以下问题:TypeScript NgZone类的具体用法?TypeScript NgZone怎么用?TypeScript NgZone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NgZone类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: _createNgZone
function _createNgZone(givenReporter: Function): NgZone {
var defaultErrorReporter = (exception, stackTrace) => {
var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n");
DOM.logError(`${exception}\n\n${longStackTrace}`);
throw exception;
};
var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter;
var zone = new NgZone({enableLongStackTrace: assertionsEnabled()});
zone.initCallbacks({onErrorHandler: reporter});
return zone;
}
开发者ID:cedriclam,项目名称:angular,代码行数:13,代码来源:application.ts
示例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;
}
}
开发者ID:844496869,项目名称:angular,代码行数:9,代码来源:ng_zone_spec.ts
示例3: macroTask
macroTask(() => {
_zone.runOutsideAngular(() => {
promise = PromiseWrapper.resolve(4).then((x) => PromiseWrapper.resolve(x));
});
promise.then(_log.fn('promise then'));
_log.add('zone run');
});
开发者ID:844496869,项目名称:angular,代码行数:8,代码来源:ng_zone_spec.ts
示例4: 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)');
});
开发者ID:844496869,项目名称:angular,代码行数:9,代码来源:ng_zone_spec.ts
示例5: BaseException
macroTask(() => {
var c: PromiseCompleter<any> = PromiseWrapper.completer();
_zone.run(() => {
TimerWrapper.setTimeout(() => {
TimerWrapper.setTimeout(() => {
c.resolve(null);
throw new BaseException('ccc');
}, 0);
}, 0);
});
c.promise.then((_) => {
expect(_traces.length).toBe(1);
expect(_traces[0].length).toBeGreaterThan(1);
async.done();
});
});
开发者ID:844496869,项目名称:angular,代码行数:18,代码来源:ng_zone_spec.ts
注:本文中的angular2/src/core/zone/ng_zone.NgZone类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论