Skip to content

A patient version of jQuery.when() that waits for all its input promises to have a final state before resolving/rejecting the composite returned promise. Also supports 'progress' notifications.

License

Notifications You must be signed in to change notification settings

galbi101/jquery-whenall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery.whenAll()

$.whenAll() is a small utility function that, like $.when() that it decorates, aggregates multiple promises into a single promise, but unlike the later, it always waits for all promises to have a final state, either resolved or rejected, before finalizing the returned promise.

The function also supports the unique jQuery Deferred progress notifications and implements its own notifying rules for the returned promise (see the respective comment in Usage).

Installation

$ npm install jquery-whenall

Usage

$.whenAll(promise1, promise2) // promise3, ...
	.done(function() {
		// Called when all promises are resolved
	})
	.fail(function() {
		/*
		 Called when all promises have a final state (resolved/rejected),
		 and at least one of them is rejected.
		 */
	})
	.always(function() {
		// Called when all promises have a final state (resolved/rejected)
	})
	.progress(function() {
		/*
		 Initially called when at least one promise notified a "progress"
		 by deferred.notify(), and all other promises are either
		 resolved/rejected/progressed.
		 After that, this callback will continue to be invoked for each
		 individual pending promise "progress" notification, until all
		 of them are finalized.
		 */
	});

About

A patient version of jQuery.when() that waits for all its input promises to have a final state before resolving/rejecting the composite returned promise. Also supports 'progress' notifications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published