Skip to content

Array version of Bluebird.using #733

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

Closed
kjvalencik opened this issue Aug 21, 2015 · 3 comments
Closed

Array version of Bluebird.using #733

kjvalencik opened this issue Aug 21, 2015 · 3 comments

Comments

@kjvalencik
Copy link

Sometimes it can be useful to use the using / disposer pattern with an unknown number of resources. It is possible to accomplish this with:

Promise.using.apply(null, resources.concat(function handler(a, b, c, ...) {
}))

But, it would be nice if Promise.using also accepted an array. E.g.,

Promise.using(resources, function handler() {});

My specific use case is in a CI framework that spins up a number of dependent docker containers. The disposer method will remove the containers after the handling function has resolved.

@spion
Copy link
Collaborator

spion commented Aug 21, 2015

I assume that the array of resources will be passed to the handler as a single argument?

+1

@kjvalencik
Copy link
Author

I think that makes the most sense.

@benjamingr
Copy link
Collaborator

Hmm, the part that bothers me here is the fact that no other language/system with resource management provides this - there is something a little mutually exclusive between deterministic disposing of resources and a dynamic amount - I've never run into it in C# nor Python nor Java nor other languages I've used with resource management of that sort.

The container use case does sound like a very solid one - so I'm in favour of some sugar, fwiw in ES2015 it's:

Promise.using(...resources, (...handlers) => {

});

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

No branches or pull requests

4 participants