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

Array version of Bluebird.using #733

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

Comments

Projects
None yet
4 participants
@kjvalencik

kjvalencik commented Aug 21, 2015

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

This comment has been minimized.

Show comment
Hide comment
@spion

spion Aug 21, 2015

Collaborator

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

+1

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

This comment has been minimized.

Show comment
Hide comment
@kjvalencik

kjvalencik Aug 21, 2015

I think that makes the most sense.

kjvalencik commented Aug 21, 2015

I think that makes the most sense.

@benjamingr

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Aug 24, 2015

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) => {

});
Collaborator

benjamingr commented Aug 24, 2015

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