Last active
April 27, 2019 20:48
Revisions
-
marta-krzyk-dev revised this gist
Apr 27, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ let winIceCream = function(message) { }); }; cleanRoom.then(function(result){ return removeGarbage(result); }).then(function(result) { return winIceCream(result); -
marta-krzyk-dev created this gist
Apr 26, 2019 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ //From: https://www.youtube.com/watch?v=s6SH72uAn3Q { //Declare scope let cleanRoom = function(message) { return new Promise(function(resolve, reject) { resolve(message + ' I cleaned the room!'); }); }; let removeGarbage = function(message) { return new Promise(function(resolve, reject) { resolve(message + ' I removed garbage!'); }); }; let winIceCream = function(message) { return new Promise(function(resolve, reject) { resolve(message + ' I won ice cream!'); }); }; promiseToCleanRoom.then(function(result){ return removeGarbage(result); }).then(function(result) { return winIceCream(result); }).then(function(result){ console.log('I\'m finished! ' + result); }); Promise.all([cleanRoom(), removeGarbage(), winIceCream()]) .then(function(){ console.log('All finished!!'); }); Promise.race([cleanRoom(), removeGarbage(), winIceCream()]) .then(function(){ console.log('At least one of them is finished!!'); }); } // End scope