NgZone中hasPendingMacrotasks或hasPendingMicrotasks有什麼區別?文件似乎缺乏信息。我所知道的是他們返回一個布爾值。但他們究竟在檢查什麼?什麼被認爲是一項微觀任務?什麼被認爲是一項宏觀任務?hasPendingMacrotasks和hasPendingMicrotasks檢查什麼?
class NgZone {
static isInAngularZone() : boolean
static assertInAngularZone() : void
static assertNotInAngularZone() : void
constructor({enableLongStackTrace = false}: any)
run(fn:() => any) : any
runGuarded(fn:() => any) : any
runOutsideAngular(fn:() => any) : any
onUnstable : EventEmitter<any>
onMicrotaskEmpty : EventEmitter<any>
onStable : EventEmitter<any>
onError : EventEmitter<any>
isStable : boolean
hasPendingMicrotasks : boolean
hasPendingMacrotasks : boolean
}
我最好的猜測是,微指任務從一個特定的類中,而宏觀大概是指一個任務在關於整個應用程序。任何人都可以驗證或確認這個假設?或者說明一些細節?
NgZone文檔:
https://angular.io/docs/ts/latest/api/core/index/NgZone-class.html#!#hasPendingMicrotasks-anchor
見謝謝你這有助於明確一些事情了。 –