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

new Promise.all() #13

Open
xilibro opened this issue Apr 7, 2017 · 1 comment
Open

new Promise.all() #13

xilibro opened this issue Apr 7, 2017 · 1 comment

Comments

@xilibro
Copy link

xilibro commented Apr 7, 2017

const iconsLoaded = new Promise((resolve, reject) => {
	new Promise.all(
		Object.keys(icons).map(iconName =>
		// IconName--suffix--other-suffix is just the mapping name in iconsMap
		Ionicons.getImageSource(
		iconName.replace(replaceSuffixPattern, ''),
		icons[iconName][0],
		icons[iconName][1]
		))
	).then(sources => {
		Object.keys(icons)
		.forEach((iconName, idx) => (iconsMap[iconName] = sources[idx]));

		// Call resolve (and we are done)
		resolve(true);
	});
});

who can help me understand why following code working:
new Promise.all().then() ... i test this code in jsfiddle tell me an TypeError:
Promise.all is not a constructor

@Afulton11
Copy link
Contributor

Probably a bit late on this, but
Just use:

Promise.all

instead of

new Promise.all()

all is a static function of Promise.

Promise.all() on Mozilla docs

junedomingo added a commit that referenced this issue Jun 11, 2017
Fix duplicate keys, refactor for issue #13
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

2 participants