Skip to content

Instantly share code, notes, and snippets.

@rimian
Created February 5, 2019 02:32
Show Gist options
  • Save rimian/e5d88017653f6af439334210dafbf023 to your computer and use it in GitHub Desktop.
Save rimian/e5d88017653f6af439334210dafbf023 to your computer and use it in GitHub Desktop.
Promises
done = (msg, delay) => {
console.warn(msg, delay);
return msg;
};
p = (msg, delay) => new Em.RSVP.Promise((resolve) => Em.run.later(() => resolve(done(msg, delay)), delay) );
fast = [p('fast one', 3223), p('fast two',3509)];
slow = [p('slow one', 15523), p('slow two', 15509)];
Em.RSVP.all(slow).then((r) => {
console.warn(0, r);
return Em.RSVP.all(fast);
}).then((r) => console.warn(1, r));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment