Every task has it's own "context" unless you want to clobber globals
console.log('start');
console.log('enqueue');
setTimeout(function () {
console.log('task');
console.log('dequeue');
}, 100);
console.log('end');
Zone.run(function () {
console.log('start');
setTimeout(function() {
console.log('task');
}, 100);
console.log('end');
});
zone.fork({
beforeTask: function () {
console.log('hi');
}
}).run(function () {
// do stuff
});
function myZone() {
var _alert = window.alert,
_alertConsole = function (msg) { console.log(msg); };
return {
beforeTask: function () { window.alert = _alertConsole; },
afterTask: function () { window.alert = _alert; }
};
}
function myZone() {
return {
$afterTask: function (parent) {
return function () { /* do stuff before */
parent(); /* do stuff after */ }; },
'+afterTask': function () { /* runs after parent */ },
'-afterTask': function () { /* runs before parent */ },
};
}