What is Async JavaScript?

preview_player
Показать описание
Learn about asynchronous behavior in JavaScript.

Learn about callbacks for async flow control:

and promises:

Рекомендации по теме
Комментарии
Автор

This is a great intro to async JavaScript, Kyle! Thank you for sharing.

seunoshitade
Автор

Kyle - you explained it so well. was struggling to understand the concept of async and how to deal with using callback and promises

shashank
Автор

this is a great starting point to understand the world of async flow control in js. thanks for sharing!

undefBehav
Автор

Kyle, I love the fact that you used the debugging tool with the breakpoints to visually show the asynchronous flow.

kim-nafamily
Автор

Explained so well! Easy for me to understand. Thanks a lot!

longchhun
Автор

Yes your back! Was wondering where you were!

jackninja
Автор

i just subscribed after watcing 2 minutes. great tutorial mate

Heyhey_time
Автор

This video was highly enlightening. Thank you so much for doing this and helping me understand asynchronous code better. One question though, in the parameters of the anonymous function, how do the parameters know where to go?

Take 2:50 for example. You say "per the node js convention, the first argument passed back is if there's an error and the second one is the contents of the file that we've read." So how does the actual error know to go to the "err" parameter and not end up in the "one" parameter? Does the error always go to the first paremeter, no matter what its called? Such that if we named the first parameter "one" and the second parameter "err", the error would go to the "one" parameter instead?

I hope this explains my question well.

SogMosee
Автор

Great job finally heard something I've been searching for in your video (and I've watched and read a lot on this) and that is that the async functions get executed, paused and resumed (over and over until complete) to allow other code to share the thread, essentially time sharing it. Now what makes an async function able to do this as opposed to regular code? And besides the built in or third party functions that are already async enabled how can I make my custom function async compliant? If you can answer these questions I think it will really help me get my brain around this. Thank Keep up the good work.

bradsatz
Автор

First off I love the bear analogy!
So, you seem to have confirmed what I originally suspected was going on. That is once an asynchronous code chuck starts to execute it will not get interrupted. If that code takes 30 minutes it will temporarily block everything for 30 continuous minutes. Effectively when you write asynchronous code you are merely allowing places in your code for things outside of your program to get a chance to execute. Everything I read says "when you have a long running function make it async so you don't block", but it sounds like it's going to block, you are just putting it into a queue for later. So really if you have a "long running function" does it really have benefits running async? At best you just delayed it? Seems to me async code funcs need to execute quick for them to make sense or have a benefit. Also from your reply you confirmed that no two async functions execute at the same time. Do I have this all correct?

bradsatz
Автор

Now on making your own custom asynchronous functions. You seem to have confirmed what I have found out there (amongst very poor explanations), that being you can't make your own. At best you can piggyback on one of the pre-existing specific javascript engine implementation extension functions. These actually run in a separate thread in the larger mechanism that hosts the JavaScript engine (like a browser or Node). Some of these extension functions take your custom callback function and place it on the event queue. Thus you are effectively hijacking one of these to get your code on the queue. I think this is what all the JS frameworks are really doing under the covers. Do I have this correct? Thanks again!

bradsatz
Автор

Hi Kyle, great video as always! What about if I want to implement an async callback in my function, what should I do?

niccolomarcon
Автор

thanks for this. by the way, do you have your demo files uploaded to somewhere just to explore more? hehe thank you again.

zimmoncastro
Автор

A thing i never see is who takes care of tasks beeing processed like actual network calls etc. Javascript engine waits for an event To continue when it s done.. .but what about the calls? It should be worth talking about thé browser itseilf i think

lutaseb
Автор

Can you make another, simpler video on callbacks and promises? I tried to understand the ones you already did but got lost. I've tried watching them multiple times too :/ I understand if u can't, but I'd appreciate it! Maybe I should start at the beginning of your videos, perhaps that'll help.

MrVontar