Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Foo() {
- var promises = new Array(n);
- for (var i = 0; i < n; i++) {
- promises[i] = new Array(m);
- }
- var i = 0, j;
- list1.forEach(el1 => {
- j = 0;
- list2.forEach(el2 => {
- promises[i][j] = promises[j][i] = GetSomePromise();
- j++;
- });
- i++;
- });
- Promise.all(promises).then(result => {
- // tutaj result zawiera pending promises
- }).catch(error => {
- alert(error);
- });
- }
- GetSomePromise() {
- return new Promise((resolve, reject) => {
- someFunction(
- result => { //callback
- if (rseult !== undefined) {
- resolve(result);
- } else
- reject(0);
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement