I trying to use _.find() in the context of a Q promise.
My problem seems to be from the fact that my predicate function contains a call to an asynchronous (node-style) function.
Here is my code:
var IsAlreadyQueued = function() {
    return Q.ninvoke(kueSearcher, 'delayed')
        .then(function(ids) {
            return Q(_.find(ids, function(id) {
                // return true; // This works
                kue.Job.get(id, function(err, job) {
                    if (job.type === 'jobtype') {
                        return true;
                    }
                });
            }));
        });
};
So as I said in comments in the code, if i do return true; instead of calling kue.Job.get() it works.
Can you see what's wrong with my use of _.find() in a promise?
Thanks a lot for your help.
 
     
    