Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving Promises Within Workers #119

Closed
Weblors opened this issue Jun 27, 2016 · 6 comments
Closed

Resolving Promises Within Workers #119

Weblors opened this issue Jun 27, 2016 · 6 comments

Comments

@Weblors
Copy link

Weblors commented Jun 27, 2016

This is my code:

            let p = new Parallel(businessChunks);

            let result = yield p.map(businessIds => {
                'use strict';

                const Promise = require('bluebird');
                const BusinessReport = require(process.cwd() + '/bin/dataExport/business');

                return Promise.map(
                    businessIds,
                    businessId => {
                        let businessReport = new BusinessReport(businessId, {
                            qbConnectionString: 'address',
                            botId: 'id'
                        });

                        return businessReport.generate();
                    },
                    {
                        concurrency: process.env.TASK_CONCURRENCY
                    }
                );
            });

As you can see, within each worker I'm doing lots of asynchronous stuff using bluebird's promise library and I want the result if that to be returned. But the output gives me four promise objects. How do I get this to work?

@amilajack
Copy link
Member

This project doesnt really get that much support anymore. I would recommend using another library that does.

@amilajack
Copy link
Member

@Weblors
Copy link
Author

Weblors commented Jun 27, 2016

@amilajack any suggestions?

@amilajack
Copy link
Member

Good question. Over the past few weeks I've been looking for a WebWorker lib that actually works. About 90% of them don't work properly. I think you should check out:

https://github.com/steelbrain/Worker-Exchange

I personally haven't used it yet but it looks very promising. Tests are at 100% coverage:
https://travis-ci.org/steelbrain/Worker-Exchange

@amilajack
Copy link
Member

amilajack commented Jun 27, 2016

I would also search npms.io for packages. They sort npm repos based on their quality. This project is a rated a 3/100:

screen shot 2016-06-27 at 10 42 06 am

@Weblors
Copy link
Author

Weblors commented Jun 28, 2016

Thanks, mate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants