Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 787a1b4c

Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)

dropped Utils.promiseAll() method, use native Promise.all() instead

Zobrazit rozdíly:

sources/src/main/webapp/js/utils/utils.js
35 35
		return typeof variable === 'undefined';
36 36
	}
37 37

  
38
	/**
39
	 * Returns a new promise that is resolved at the moment when all promises passed as function parameter are resolved.
40
	 * {@link https://stackoverflow.com/a/35825493}
41
	 * 
42
	 * @param promises Array of promises to wait for.
43
	 * @return New promise.
44
	 */
45
	static promiseAll(promises) {
46
		if (!Array.isArray(promises)) {
47
			throw new TypeError('Parameter must be an array.');
48
		}
49

  
50
		return $.when.apply($, promises).then(function () {
51
			// if single argument was expanded into multiple arguments, then put it back into an array for consistency
52
			if (promises.length === 1 && arguments.length > 1) {
53
				return [ Array.prototype.slice.call(arguments, 0) ];
54
			} else {
55
				return Array.prototype.slice.call(arguments, 0);
56
			}
57
		})
58
	}
59

  
60 38
	/**
61 39
	 * Extracts value of a query parameter from the current URL.
62 40
	 * {@link https://css-tricks.com/snippets/javascript/get-url-variables/}

Také k dispozici: Unified diff