Last active
November 16, 2018 09:07
-
-
Save andrewlistopadov/53b0ec622be7848466084b5fcd90402d to your computer and use it in GitHub Desktop.
Revisions
-
andrewlistopadov revised this gist
Nov 16, 2018 . 1 changed file with 9 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 @@ -1,4 +1,4 @@ function getRejectedPromise() { const promise = new Promise((resolve, reject) => { reject('some error'); }); @@ -8,10 +8,14 @@ function func() { let counter = 0; const interval = setInterval(() => { if (++counter > 10) clearInterval(interval); else console.log(`async counter: ${counter}`); }, 500); getRejectedPromise() .then(() => console.log('Never be called. But rejection will not be visible in the console and main thread will be alive.')); console.log('will be reached'); setTimeout(() => console.log('2nd async console output'), 3000); setTimeout(() => console.log('1 async console output'), 0); setTimeout(() => console.log('last async console output'), 6000); -
andrewlistopadov renamed this gist
Nov 16, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
andrewlistopadov created this gist
Nov 16, 2018 .There are no files selected for viewing
This file contains hidden or 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,17 @@ function func() { const promise = new Promise((resolve, reject) => { reject('some error'); }); return promise; } let counter = 0; const interval = setInterval(() => { if (++counter > 10) clearInterval(interval); else console.log(`count: ${counter}`); }, 500); func() .then(() => console.log('never be called')); console.log('will be reached');