Skip to content

Instantly share code, notes, and snippets.

@JiaLiPassion
Last active July 10, 2018 07:24
Show Gist options
  • Save JiaLiPassion/a88c124a58a8e3475100d57c11805efe to your computer and use it in GitHub Desktop.
Save JiaLiPassion/a88c124a58a8e3475100d57c11805efe to your computer and use it in GitHub Desktop.
var zoneA = Zone.current.fork({name: 'zoneA'});
function callback() {
// Javascript engine context 2
// Zone Context: zoneA
// we can access the async execution context by call Zone.current
console.log('ctx', Zone.current.name); // will be zoneA
}
window.onload = zoneA.wrap(function() {
// Javascript engine context 1
// Zone Context: zoneA
console.log('ctx', Zone.current.name); // will be zoneA
setTimeout(zoneA.wrap(callback), 100);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment