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

How to wait till all promises complete #79

Closed
johneke opened this issue Sep 17, 2016 · 4 comments
Closed

How to wait till all promises complete #79

johneke opened this issue Sep 17, 2016 · 4 comments
Milestone

Comments

@johneke
Copy link

johneke commented Sep 17, 2016

I currently have code like this:

            DeferredManager d = new DefaultDeferredManager();
            dman
            .when(new DeferredObject().reject(""), new DeferredObject().promise(), new DeferredObject().promise())
            .then(new DoneCallback<MultipleResults>()
            {
                @Override
                public void onDone(MultipleResults result)
                {
                    System.out.println("done called");
                }
            })
            .fail(new FailCallback<OneReject>()
            {
                @Override
                public void onFail(OneReject result)
                {
                    System.out.println("fail called");
                }
            })
            .always(new AlwaysCallback<MultipleResults, OneReject>()
            {
                @Override
                public void onAlways(Promise.State state, MultipleResults resolved, OneReject rejected)
                {
                    System.out.println("always called");
                }
            });

I am noticing that right away onFail gets called and onAlways gets called, since the first promise is rejected. It doesn't matter that all other promises in the chain are pending.

This is fine, but is there any way I can wait for all promises in the deferred manager to resolve/reject? And then collect them all together? I am looking for something similar to when.settle() in when.js

@saturnism
Copy link
Member

This sounds like a good enhancement!

@johneke
Copy link
Author

johneke commented Sep 21, 2016

Haha sounds good, I assumed it was possible and I just didn't know how to do it.

Ill work on a PR! Thanks!

@saturnism saturnism added this to the 2.0 milestone Jun 21, 2017
@mrmaffen
Copy link
Contributor

mrmaffen commented Aug 6, 2017

done #118

@saturnism
Copy link
Member

This is added in #128, cheers!

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

3 participants