You've successfully subscribed to What's Brian Doing
Great! Next, complete checkout for full access to What's Brian Doing
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Learning Javascript

Learning Javascript

Followed Tyler McGinnis's course a bit today. Specifically, I watched the lecture "The Evolution of Async JavaScript: From Callbacks, to Promises, to Async/Await"

Brian Ross
Brian Ross

Followed Tyler McGinnis's course a bit today.  Specifically, I watched the lecture "The Evolution of Async JavaScript: From Callbacks, to Promises, to Async/Await"

It's a very different development course than others I've followed.  McGinnis provides detailed explanation of the concepts with very straight forward examples. It seems effective, though I suspect it may be more effective for more seasoned developers transitioning to Javascript.  I will likely follow a more hands on tutorial once I'm through this course.  And, I'll likely return to the written lecture notes McGinnis provides as reference material frequently.

He created this CodeSandBox as a demonstration.  The lecture goes through fulfilling this capability via CallBacks, then Promises and finally Await/Async.

CodeSandBox

I must say, Callbacks, Promises and Async/Await are clearer to me now.  Some key takeaways:

  • Callbacks force on to think non-sequentially.
  • Callback Hell is a problem:  the idea; nested callbacks have bad readability.
    This can be improved by  making code modular; but one still has callback hell.
  • Callbacks also have inversion of control issue. When you ask a 3rd party to invoke a callback, you defer control to them and trust them to pass the appropriate parameters.
  • Promises are designed to improve this.
  • Promises are created by creating a new instance of a Promise().
  • Promises take a callback with an object that is passed to arguments: resolve (fulfilled) and reject (rejected).
  • "One thing we haven’t talked about yet is what a promise actually is. When you create a new Promise, you’re really just creating a plain old JavaScript object. This object can invoke two methods, then, and catch. Here’s the key. When the status of the promise changes to fulfilled, the function that was passed to .then will get invoked. When the status of a promise changes to rejected, the function that was passed to .catch will be invoked."

There's more, and I should re-review the Asysc/Await stuff.  It was easy to follow, so my notes and established understanding is a bit light.


Matamo Privacy Minded Analytics: