Last active
March 25, 2019 12:08
-
-
Save JiaLiPassion/93cf4e3b186bcfedf8f92165b5aed190 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var zone = Zone.current.fork({ | |
name: 'hook', | |
onScheduleTask(delegate, current, target, task) { | |
console.log('schedule ZoneTask', task.type, task.source); | |
return delegate.scheduleTask(target, task); | |
}, | |
onInvokeTask(delegate, current, target, task, applyThis, applyArgs) { | |
console.log('invoke ZoneTask', task.type, task.source); | |
return delegate.invokeTask(target, task, applyThis, applyArgs); | |
}, | |
onHasTask(delegate, current, target, hasTaskState) { | |
console.log('hasTask state: ', hasTaskState); | |
return delegate.hasTask(target, hasTaskState); | |
} | |
}); | |
zone.run(() => { | |
setTimeout(function() { | |
console.log('timer callback invoked'); | |
}, 1000); | |
}); | |
// schedule ZoneTask macroTask setTimeout | |
// hasTask state {macroTask: true, microTask: false, eventTask: false} | |
// invoke ZoneTask macroTask setTimeout | |
// timer callback invoked | |
// hasTask state {macroTask: false, microTask: false, eventTask: false} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment