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

Allow multiple promises at a time?? #53

Open
msnpr567 opened this issue Dec 18, 2014 · 4 comments
Open

Allow multiple promises at a time?? #53

msnpr567 opened this issue Dec 18, 2014 · 4 comments

Comments

@msnpr567
Copy link

I want to use angular-busy loader for a time of 5 successive requests , can i use it ?? then how??
(or)
can i include multiple promises at a time?

@cgross
Copy link
Owner

cgross commented Dec 18, 2014

If you are using a regular promise chain then just assign the promise from the last then() to cg-busy like:

$scope.myBusyPromise = $http(...).then(function(data){
    ...
}).then(function(data){
   ...
}).then(function(data){
   ...
}).then(function(data){
   ....
});

@cgross
Copy link
Owner

cgross commented Dec 18, 2014

If they're all-at-once instead of in-a-row then just use $q.all()

@naysayer
Copy link

naysayer commented Jan 9, 2015

@cgross could you give an example of how to use $q.all()? I am in a situation where I have a dynamic number of calls being made and would like the loading icon to be displayed until they are all complete. Thanks in advance.

@fabiosussetto
Copy link

@naysayer example:

// controller
$scope.allDonePromise = $q.all([promise1, promise2, ...]);

// template
<div cg-busy="allDonePromise">

The spinner will be shown until all the promises will be resolved. Note the promises cab be run in parallel.
From Angular docs:
"$q.all(): Combines multiple promises into a single promise that is resolved when all of the input promises are resolved."
CgBusy is very cool because he doesn't care about http requests, all it cares about are promises.

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

4 participants