Javascript 用于并行独立任务的Bluebird

Javascript 用于并行独立任务的Bluebird,javascript,ecmascript-6,bluebird,es6-promise,Javascript,Ecmascript 6,Bluebird,Es6 Promise,假设我想在从数据库中查找用户的同时发送一封电子邮件并将通知推送到客户端,我可以这样写 User.findById(userId).exec() .then(() => sendMail()) .then(() => pushNotification()) 但是,既然pushNotification不一定要在sendMail之后发生,那么还有其他方法来编写它吗 var BlueBird = require('bluebird'); User.findById(userId).exe

假设我想在从数据库中查找用户的同时发送一封电子邮件并将通知推送到客户端,我可以这样写

User.findById(userId).exec()
.then(() => sendMail())
.then(() => pushNotification())
但是,既然
pushNotification
不一定要在
sendMail
之后发生,那么还有其他方法来编写它吗

var BlueBird = require('bluebird');

User.findById(userId).exec()
    .then(() => Bluebird.all([sendMail(), pushNotification()]))
将同时启动它们并等待它们。

与es6相同:

User.findById(userId).exec()
  .then(() => Promise.all([sendMail(), pushNotification()]))