Created
February 5, 2019 02:32
-
-
Save rimian/e5d88017653f6af439334210dafbf023 to your computer and use it in GitHub Desktop.
Promises
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
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