This allows you to to schedule asynchronous functions to run in squence.
var scheduler = new require('zoned-scheduler')();
var q = require('q');
console.log('first');
scheduler.schedule(() => {
console.log('second');
});
scheduler.schedule(() => {
return q.delay(100).then(() => {
console.log('third');
});
});
scheduler.schedule(() => {
console.log('fourth');
});
It uses zone.js to allow you to schedule one task inside another:
console.log('first');
scheduler.schedule(() => {
console.log('second');
scheduler.schedule(() => {
console.log('fourth');
});
return q.delay(100).then(() => {
console.log('third');
scheduler.schedule(() => {
console.log('fifth');
});
});
});
scheduler.schedule(() => {
console.log('sixth');
});
(See API.md
for a list of commands)