Further Adventures of the Event Loop - Erin Zimmer - JSConf EU 2018

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 มิ.ย. 2018
  • Most JavaScript developers are probably familiar with the event loop. It’s how JavaScript handles I/O events without blocking, even though it’s single-threaded. Event callbacks are added to the task queue. The browser then takes a callback from the queue and runs it from start to finish. Then it decides to either repaint or run another callback. Simple, right?
    But what about web workers? And promises? And what happens when your JavaScript isn’t running in a browser? In this talk, we’ll look at how multi-threaded event loops work, how promises differ from other callbacks, and what goes on in the Node event loop.
    OMG JSConf EU is coming back in 2019 2019.jsconf.eu/
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 43

  • @loophostage
    @loophostage 3 ปีที่แล้ว +12

    Better late than never! Really happy to find such informative video. It’s definitely one of the most helpful explanation how event loop works as for me. Thank you!

  • @vividhchandna
    @vividhchandna 6 ปีที่แล้ว +32

    Sad nobody got the "off by one error" joke at 17:55. Nice one.

  • @lebon1211
    @lebon1211 2 ปีที่แล้ว +2

    Wow. This really took everything I knew and connected the dots so clearly! Well done!!

  • @davlad32
    @davlad32 2 ปีที่แล้ว +1

    Great talk, this cleared up some big misconceptions I had about this topic. I'm really glad that I didn't have to skim through another class on the concept of callbacks/promises to get this info.

  • @bubucuo9195
    @bubucuo9195 ปีที่แล้ว

    This is absolutely one of the most helpful video about event loop. Thanks a lot.

  • @MrKar18
    @MrKar18 5 ปีที่แล้ว +2

    It clearly gave a great insight on the node js's event loop which is great to know for writing Unit tests in React ;) Since the Browser event and the NodeJs event loop are different, we mostly see workarounds involving setImmediate() in tests.

  • @ToniWCampbell
    @ToniWCampbell 6 ปีที่แล้ว +34

    The crowd wasn't very helpful with the laughs, but you did great anyways! Thanks for the talk!

    • @Gelio1234
      @Gelio1234 6 ปีที่แล้ว +3

      The "laughs" appear often, also in other talks, but only when the speaker has a short break while speaking. I believe those are not laughs from the audience, but the microphone getting more sensitive and picking up different noises that sound like laughs. This is just an idea, though :D Makes me not sorry for the speakers

    • @chipmo
      @chipmo 5 ปีที่แล้ว +2

      Yes, I was going to mention this as well. A lot of the bits that might sound like laughter seems much more likely they are audio artefacts as the background noise suppression kicks in.

  • @julienwickramatunga7338
    @julienwickramatunga7338 5 ปีที่แล้ว +3

    Nice and helpful talk, it's indeed a good sequel to Phil Robert's. Thank you very much :-)

  • @kajalgupta2964
    @kajalgupta2964 3 ปีที่แล้ว

    Stupendous! Explanation. I am all clear with event loop now

  • @gauthierpeel5620
    @gauthierpeel5620 5 ปีที่แล้ว +1

    very good talk : i learned a lot and easily, thanks !

  • @RichFinelli
    @RichFinelli 2 ปีที่แล้ว +1

    Thanks for explaining what a 'microtask' is. I'm working with testing async stuff in Angular and couldn't figure out something in their API called 'flushMicrotasks' and your talk helped! Thanks

  • @chrissherlock1748
    @chrissherlock1748 6 ปีที่แล้ว

    Brilliant talk! Thanks so much!

  • @aligarajian8806
    @aligarajian8806 3 ปีที่แล้ว

    That was awesome! Two thumbs up 👍👍

  • @brokenumbrellagames
    @brokenumbrellagames 6 ปีที่แล้ว +2

    Really nice talk! Thanks!

  • @lukaszollner2352
    @lukaszollner2352 3 ปีที่แล้ว

    Great talk, learned a lot, thank you =)

  • @junezlx9236
    @junezlx9236 3 ปีที่แล้ว

    this is really very nice explanation

  • @11Scorpion
    @11Scorpion ปีที่แล้ว

    great content, great explanation

  • @user-uf3vm9jl4g
    @user-uf3vm9jl4g 3 ปีที่แล้ว

    brilliant talk, thanks

  • @rpferrao
    @rpferrao 6 ปีที่แล้ว +2

    Loved it, something that seemed complicated is actually dead simple!

  • @sasha_prisyazhnyy
    @sasha_prisyazhnyy 2 ปีที่แล้ว +2

    This is a great talk. Thank you Erin for translating the concept into a JavaScript developer language I can understand.
    I've got one question though - why everybody's got vodka on their tables?

  • @stonesnicola9439
    @stonesnicola9439 3 ปีที่แล้ว

    Very nice! Thank you!

  • @user-el9pr6ow9l
    @user-el9pr6ow9l 5 ปีที่แล้ว

    Nice talk! Thanks

  • @passby8070
    @passby8070 4 ปีที่แล้ว

    great talk!

  • @cheeru100
    @cheeru100 5 ปีที่แล้ว

    very helpful~ Thanks

  • @andriihordynskyi8778
    @andriihordynskyi8778 3 ปีที่แล้ว +1

    A really great topic she has covered.
    Great jokes tho.
    This audition should've been listening to her in the beginning..

  • @oathkitchenzhao9206
    @oathkitchenzhao9206 2 ปีที่แล้ว

    really helpful, thanks

  • @kushal1
    @kushal1 3 ปีที่แล้ว +1

    One mistake I feel in the explanation of event loop.
    If a queue task is picked up first. Then microtask loops. Not true. If microtask has any task it is given priority. Not the way the sequence is written in slide. According to slides, as soon as callstack is empty it pops up queue tasks first and then goes to a microtask loop. Try running below code and the output would be 10, 30, 20.
    ```
    function abc(){
    console.log(10);
    setTimeout(() => console.log(20), 0);
    Promise.resolve(30).then(res => console.log(res));
    }
    abc();
    ```

  • @vladlazar94
    @vladlazar94 ปีที่แล้ว

    I believe final snippet (14:03) is not entirely accurate. The microtask queue also flushes between animation tasks. It basically flushes every time the call stack returns.

  • @khalilliu1534
    @khalilliu1534 5 ปีที่แล้ว

    super clear

  • @rdandnayak
    @rdandnayak 6 ปีที่แล้ว

    Very nice

  • @imhererahul
    @imhererahul 2 ปีที่แล้ว

    hi, great talk !! But I have a doubt. From what I've read, the microtask queue has more priority than callback queue ? But according to the pseduo code, the callback queue(next task queue ?) has more priority. Can anymore correct my understanding ?

  • @forceboxed
    @forceboxed 2 ปีที่แล้ว

    12:42
    It's doing nothing only if the element did have the "slide" class already applied to it. If not, then after those two statements, it will have the class applied to it.

  • @ajayChauhan-nt5xm
    @ajayChauhan-nt5xm 4 ปีที่แล้ว

    With such sharp voice she could be a Chorister in orchestra bands

  • @theonlycatonice
    @theonlycatonice 3 ปีที่แล้ว +1

    10:03 Ah yes pretty much a daily occurrence in software devving

  • @peteranthonyduot6027
    @peteranthonyduot6027 4 ปีที่แล้ว

    I thought that microtasks/services are being processed if there are 0 tasks in the current task list? I'm confused now.

    • @erinzimmer9959
      @erinzimmer9959 4 ปีที่แล้ว +3

      Microtasks get processed when the stack is empty, which is a bit different to the current task list. Have a look at What the Heck is the Event Loop for more information about that side of things (th-cam.com/video/8aGhZQkoFbQ/w-d-xo.html)

  • @prajwaljain1282
    @prajwaljain1282 ปีที่แล้ว

    isn't `taskQueue` a queue? And pop() will pop the element(task) from the end of the array (LIFO)?

  • @ravimone1
    @ravimone1 2 ปีที่แล้ว +1

    Hello @JSConf, first of all, this is great community and this video is awesome , but just wanted to highlight a correction here @1:22, instead of this line `task = taskQueue.pop(); => task = taskQueue.dequeue(); `, would have made more sense

  • @user-kn3wo3vp5h
    @user-kn3wo3vp5h 5 หลายเดือนก่อน

    Thanks for the wonderful speech.
    I have a question to ask:
    ```
    setTimeout(() => {
    console.log("timeout 1");
    requestAnimationFrame(() => console.log("rAF callback"));
    const now = performance.now();
    while(performance.now() - now < 2) {} // lock the event loop
    });
    setTimeout(() => console.log("timeout 2"));
    ```
    Sometimes the result is: timeout 1、timeout 2、rAF callback
    Sometimes the result is: timeout 1、rAF callback、timeout 2
    Is this related to isRepaintTime? How to judge this?