movieapp icon indicating copy to clipboard operation
movieapp copied to clipboard

new Promise.all()

Open xilibro opened this issue 7 years ago • 1 comments

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

xilibro avatar Apr 07 '17 16:04 xilibro

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

Afulton11 avatar May 26 '17 20:05 Afulton11