This is a continuation of Writing Async Javascript Code in Sync Format – Part 1
There’s a new es6 feature called Destructuring Assignment that looks like this:
1 2 3 4 5 6 |
|
Keep in mind that objects can mimic arrays so this works:
1 2 3 |
|
There’s also a shortcut available for assigning to objects in es6 where var {x:x, y:y}
can be written as var {x, y}
This means we could have written
1 2 3 |
|
Using this knowledge and what we did in the first part we can write really cool concurrent code:
Promise.props
is a bluebird specific function that does what Promise.all
except on objects. If you’re using native Promises it doesn’t take much to polyfill it