I figured out the problem. `callbackFlow()` was being executed before than 
`resultList.push()`, so I had to put `callbackFlow()` inside of 
`indicador.execute` as:

    indicador.execute(item, data.fechamento, function(result) {
        resultList.push(result);
        callbackFlow();
    });




Em quarta-feira, 24 de setembro de 2014 08h46min27s UTC-3, Kleyson Rios 
escreveu:
>
> I have the following code:
>
>
> var flow = require('nimble');
>
> exports.execute = function(data, estrategias, callback) {
>
>     var estrategiaList = [];
>     var resultList = [];
>
>     for (var i in estrategias)
>     {
>             var estrategia = (function(item) {
>
>                     return function(callbackFlow) {
>
>                             // Cria uma nova instancia do indicador
>                             var indicador = loadIndicador(item);
>
>                             // Executa indicador
>                             indicador.execute(item, data.fechamento, 
> function(result) {
>                                     resultList.push(result);
>                             });
>
>                             callbackFlow();
>                     }
>
>             })(estrategias[i]);
>
>             estrategiaList.push(estrategia);
>     }
>
>     flow.parallel(estrategiaList, function() {
>             callback(resultList);
>     });
> };
>
>
>
>
> For some reason on the final flow.parallel callback `callback(resultList)` 
> I'm getting the resultList empty.
>
> I've checked that `resultList.push(result)` add successfully the result 
> in the resultList array.
>
> I think the problem is some small detail that I couldn't figured out.
>
> Can someone help me ?
>
> Regards. 
>
> Kleyson Rios.
>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/7e3e6bef-9088-4d67-85f0-3c8500ef98b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to