How to use when/parallel

73 Views Asked by At

I'm a bit stumped at what I might be doing wrong when I'm trying to use the when.js parallel function:

https://github.com/cujojs/when/blob/master/docs/api.md#whenparallel

var parallel = require('when/parallel');

var resultsPromise = parallel(arrayOfTasks, arg1, arg2 /*, ... */);

As far as I understand arrayOfTasks can be an array of Promises? But I run into the error "TypeError: task.apply is not a function" when I try to replace a when.all with parallel like this:

var when = require('when');
var parallel = require('when/parallel');

var arrayOfPromises = [
    when.resolve('a'),
    when.resolve('b'),
    when.resolve('c'),
];

return parallel(arrayOfPromises)
    .then(function(parseResultArray) {
        console.log("result", parseResultArray);
    });
0

There are 0 best solutions below