是否$q
包含隐式摘要/适用于承诺链的解决/拒绝?
我已经迁移了一段代码$q
以供使用q
,现在似乎缺少摘要,从而导致不同的行为。为什么会这样?
是否$q
包含隐式摘要/适用于承诺链的解决/拒绝?
我已经迁移了一段代码$q
以供使用q
,现在似乎缺少摘要,从而导致不同的行为。为什么会这样?
甚至更多 - 它包括明确的,只要QProvider
定义如下:
function $QProvider() {
this.$get = ['$rootScope', '$exceptionHandler', function($rootScope, $exceptionHandler) {
return qFactory(function(callback) {
$rootScope.$evalAsync(callback); // ! $evalAsync()
}, $exceptionHandler);
}];
}
从这个函数声明中,有一个简短的方法来.$evalAsync()
实现 versin 1.2.28 看起来像
$evalAsync: function(expr) {
// if we are outside of an $digest loop and this is the first time we are scheduling async
// task also schedule async auto-flush
if (!$rootScope.$$phase && !$rootScope.$$asyncQueue.length) {
$browser.defer(function() {
if ($rootScope.$$asyncQueue.length) {
$rootScope.$digest(); // ! $digest()
}
});
}
this.$$asyncQueue.push({scope: this, expression: expr});
},