-
-
Save navix/ec0a684481cb30d38817d8f72b084ef1 to your computer and use it in GitHub Desktop.
Revisions
-
StevenACoffman revised this gist
Sep 20, 2017 . 1 changed file with 6 additions and 6 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 @@ -60,12 +60,12 @@ getData() ```javascript (async () => { try { const a = await getData(); const b = await getMoreData(a); const c = await getMoreData(b); const d = await getMoreData(c); const e = await getMoreData(d); console.log(e); } catch(me) { // if you can -
StevenACoffman revised this gist
Sep 20, 2017 . 1 changed file with 3 additions and 3 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 @@ # Async / Await in 7 seconds by Wassim Chegham (@manekinekko) From this [awesome animation](https://async-await.xyz/), originally from [this tweet](https://twitter.com/manekinekko/status/855931622780272640) @@ -20,7 +20,7 @@ getData( a => { ``` ### Promises (with anonymous functions argument) ```javascript getData() @@ -31,7 +31,7 @@ getData() .then(e => getMoreData(e)); ``` ### Promises (with named function argument) ```javascript getData() -
StevenACoffman created this gist
Sep 20, 2017 .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,74 @@ Aync / Await by Wassim Chegham (@manekinekko) From this [awesome animation](https://async-await.xyz/), originally from [this tweet](https://twitter.com/manekinekko/status/855931622780272640) ### Callbacks (continuation passing style) ```javascript getData( a => { getMoreData(a, b => { getMoreData(b, c => { getMoreData(c, d => { getMoreData(d,e => { console.log(e); }); }); }); }); }); ``` ### Promises (with anonymous functions as arguments) ```javascript getData() .then(a => getMoreData(a)) .then(b => getMoreData(b)) .then(c => getMoreData(c)) .then(d => getMoreData(d)) .then(e => getMoreData(e)); ``` ### Promises (with named function arguments) ```javascript getData() .then(getMoreData) .then(getMoreData) .then(getMoreData) .then(getMoreData) .then(getMoreData); ``` ### Async Await ```javascript (async () => { const a = await getData(); const b = await getMoreData(a); const c = await getMoreData(b); const d = await getMoreData(c); const e = await getMoreData(d); console.log(e); })(); ``` ### Async Await with Exception Handling ```javascript (async () => { try { const a = await getData(); const b = await getMoreData(a); const c = await getMoreData(b); const d = await getMoreData(c); const e = await getMoreData(d); console.log(e); } catch(me) { // if you can } })(); ```