Giter Club home page Giter Club logo

Comments (4)

cvasseng avatar cvasseng commented on July 24, 2024

There's issues with scoping in your code. The export call is async, meaning that i will always have the value of chart.length - 1 when the export callback is executed, since the callbacks will be called after the loop is done iterating.

You should also only init the pool once, as it's global. In addition, you're killing the pool after the first export returns (in the exporter.export callback), effectively canceling the next export.

Try something like:

var charts = [<array of charts meta>],
    chartResults = []
;

exporter.initPool();

charts.forEach(function (chart, i) {
    exporter.export(exportSettings, function (err, res) {
        console.log('did export', i);
        
        // Add the data to chartData
        chartResults.push(res.data);
    });
});

This will leave the pool running. If you want to run exporter.killPool (or if you want to take any other action when all the exports have completed), you should look into either Promises, or async.

from node-export-server.

wandiong avatar wandiong commented on July 24, 2024

works great, I modified some part on it based on my current needed scenario and it went as I expected. thanks a lot for helping and sorry for too long response .. totally appreciated !! 👍

from node-export-server.

cvasseng avatar cvasseng commented on July 24, 2024

No problem! Glad it worked out for you.

from node-export-server.

miniil avatar miniil commented on July 24, 2024

Hi,

Thanks for this but can you explain me or show me an example how to use Promise or async to take action when all the exports have been completed?

Thank you.

from node-export-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.