node.js - Bluebird promise.all not respecting result order -
i'm using latest stable bluebird:
"bluebird": "~3.4.0",
and following code:
promise.all([participantsservice.retrieveactiveparticipantsfromthelocaldb(), eventservice.retrieveactiveeventsfromthelocaldb(), heatservice.retrieveactiveheatsfromthelocaldb()]).then( function (results) { var namedresults = {participants: results[0], events: results[1], heats: results[2]}; return res.render('runners/runners', namedresults); }).catch( function (err) { winston.error('failed retrieve participants , or event details', err); return res.send(err); });
i expect namedresults have correct order of elements matching order in array of promises have been made not true! have different order every time.
i assuming because says on bluebird's documentation: http://bluebirdjs.com/docs/api/promise.all.html unless i'm reading wrong...
can help?
thanks
you should able use bluebird's promise.props() this:
promise.props({ participants: participantsservice.retrieveactiveparticipantsfromthelocaldb(), events: eventservice.retrieveactiveeventsfromthelocaldb(), heats: heatservice.retrieveactiveheatsfromthelocaldb() }).then(res.render.bind(res, 'runners/runners'))
Comments
Post a Comment