Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Task.all should have a canceler that cancels all the tasks passed in #260

Closed
rorticus opened this issue Jan 6, 2017 · 3 comments
Closed

Comments

@rorticus
Copy link
Contributor

rorticus commented Jan 6, 2017

Calling Task.all(...tasks).cancel() should call cancel on each of those tasks that got passed in.

Something like this might work, but hasn't really been tested, so use at your own risk :)

	static all<T>(iterable: DictionaryOfPromises<T>): Task<{ [key: string]: T }>;
	static all<T>(iterable: (T | Thenable<T>)[]): Task<T[]>;
	static all<T>(iterable: T | Thenable<T>): Task<T[]>;
	static all<T>(iterable: ListOfPromises<T>): Task<T[]>;
	static all<T>(iterable: DictionaryOfPromises<T> | ListOfPromises<T>): Task<any> {
		return new Task<T>((resolve, reject) => {
			super.all(iterable).then(<any> resolve, <any> reject);
		}, () => {
			if (isIterable(iterable) || isArrayLike(iterable)) {
				forOf(iterable, (promiseLike: any) => {
					if (isTask(promiseLike)) {
						promiseLike.cancel();
					}
				});
			}
			else {
				const promiseKeys = Object.keys(iterable);

				promiseKeys.forEach((key) => {
					const promiseLike = iterable[ key ];

					if (isTask(promiseLike)) {
						promiseLike.cancel();
					}
				});
			}
		});
	}
@eheasley eheasley added this to the 2017.01 milestone Jan 20, 2017
jacobroufa added a commit to jacobroufa/core that referenced this issue Jan 20, 2017
@dylans
Copy link
Member

dylans commented Jan 31, 2017

PR at #274

@dylans dylans modified the milestones: 2017.01, 2017.02 Jan 31, 2017
@dylans dylans modified the milestones: 2017.02, 2017.03 Mar 1, 2017
@dylans dylans modified the milestones: 2017.03, 2017.04 Apr 2, 2017
@dylans dylans modified the milestones: 2017.04, 2017.05 Apr 29, 2017
jacobroufa added a commit to jacobroufa/core that referenced this issue May 24, 2017
@jacobroufa
Copy link
Contributor

I've made the requested changes to #274, and while the build is failing it is not due to any code related to these set of commits. Please let me know if you would like me to revise anything further!

@eheasley eheasley modified the milestones: 2017.05, 2017.06 Jun 6, 2017
@eheasley eheasley removed this from the 2017.06 milestone Jun 6, 2017
@eheasley eheasley removed this from the 2017.06 milestone Jun 6, 2017
@dylans dylans modified the milestones: 2017.06, 2017.07 Jun 6, 2017
@kitsonk
Copy link
Member

kitsonk commented Jul 27, 2017

We need to follow through on this.

@kitsonk kitsonk added the beta3 label Jul 27, 2017
@kitsonk kitsonk modified the milestones: 2017.08, 2017.07 Jul 27, 2017
@kitsonk kitsonk modified the milestones: 2017.08, 2017.09 Sep 4, 2017
@kitsonk kitsonk modified the milestones: 2017.09, 2017.10 Oct 6, 2017
@kitsonk kitsonk modified the milestones: 2017.10, beta.4 Oct 30, 2017
@maier49 maier49 self-assigned this Nov 2, 2017
maier49 pushed a commit to jacobroufa/core that referenced this issue Nov 3, 2017
maier49 pushed a commit to jacobroufa/core that referenced this issue Nov 3, 2017
@maier49 maier49 closed this as completed in a29a00b Nov 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants