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

support promises in object #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

parisholley
Copy link

Allows you to send existing promises directly into the parallel call vs. wrapping in a function

@dbushong
Copy link
Owner

dbushong commented Jun 9, 2016

Two concerns:

  1. this doesn't map to functionality in async.js's parallel() call
  2. why would someone want this instead of just Q.all() ?

@parisholley
Copy link
Author

@dbushong

  1. I suppose if your goal is adhere to async.js API and not introduce the niceties of promises, sure, but it is a pretty harmless change.
  2. I do not use Q, I just use native ES6 promises, so this library serves as a nice abstraction on top of native promises.

@dbushong
Copy link
Owner

dbushong commented Jun 9, 2016

If you have ES6 promises, you have Promise.all

If you really think this'll be useful, I'm fine with it; please update the READMEs also to mention the new functionality

@parisholley
Copy link
Author

@dbushong Yes, but if I want to execute items in series, I have nothing :)

Readme updated

* tasks - An array or object containing functions to run, each function
should return a promise for an optional value.
* tasks - An array, object containing functions to run (each function
should return a promise for an optional value), or an object containing promises that resolve a value
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simpler:
"An array or object containing promises or functions to...."

@dbushong
Copy link
Owner

dbushong commented Jun 9, 2016

LGTM; one suggested simplification - btw, FFR if you really don't want to use a lib and need to execute things in series you can use reduce:

promiseForSeries = [fn1, fn2, fn3].reduce(((p, fn) => p.then(fn)), Promise.resolve())

If you have a fixed number of them, it's even more readable to use async/await (if you're using babel+esnext) or something like bluebird coroutine + yield

@dbushong
Copy link
Owner

dbushong commented Jun 9, 2016

Don't forget to run make when you're done

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

Successfully merging this pull request may close these issues.

2 participants