Web-Workers, React, and TypeScript: Off the main thread!

Sdílet
Vložit
  • čas přidán 15. 04. 2021
  • Web-Workers are an extreme powerful API which has been available for quite a while. It allow developers to split their tasks into multiple threads so the perceived performance is not damaged even when we must do extreme processing on the client-side. On this video, I will show you how to send your application state to a Web-Worker and have it processed without affecting the Main Thread performance! Blocking script? Never again! ⚡️
    ===================================
    || shameless mandatory buzzword abuse: ||
    || Web Workers are B.L.A.Z.I.N.G fast!!! ||
    ===================================
    📽 Chapters
    0:25 Install dependencies 📦
    1:16 Concepts: Sync / Async / Multi-Thread 🎓
    3:08 What are Web-Workers? 🧐
    4:34 Add Web-Worker support to tsconfig.json and webpack.config.js ⚙️
    5:49 Small CSS adjustments for presentation purposes 🎨
    6:15 Add components to App.tsx 🧩
    8:20 Create thread-blocking task 🕰
    9:41 Use the task inside a sync and inside an async function (Promise) 🙏
    10:37 Add tasks to click handlers 🐭
    12:11 Create the Web-Worker file 🚜
    12:33 What does Comlink actually do? RPC + Proxy 📡
    14:28 Add the Web-Worker to our runtime function calls in App.tsx 🛰
    15:57 Example Showdown: Sync vs Async vs Mult-Thread 🥊
    18:05 Final considerations 👋

Komentáře • 29

  • @Shakeel714
    @Shakeel714 Před 3 lety +6

    Thanks Atila, for sharing your knowledge in a very nice and easy-to-understand way. Very helpful.

  • @TeodorDimitrov1991
    @TeodorDimitrov1991 Před rokem +2

    Thank you for the video! Exactly what I was looking for.

  • @vadimk4310
    @vadimk4310 Před 3 lety

    Thank you very much! It finally helped me to make webworkers in react/typescript

  • @fatahbe7667
    @fatahbe7667 Před 11 měsíci +1

    Thanks Atila for the Video, very cool

  • @swyxTV
    @swyxTV Před 2 lety +1

    awesome explanation and demo!

  • @sexrp2380
    @sexrp2380 Před 3 lety

    Good work! I learned a lot!

  • @Avee27119
    @Avee27119 Před 2 lety

    Nice work!!

  • @xavierinthetube
    @xavierinthetube Před 3 lety

    Was the "Async on Main Thread" faster than the Sync one? It seemed to be, that'd make sense from what you explained in the beginning, but I'm not sure I understood correctly.

  • @painkiller2125
    @painkiller2125 Před 3 lety

    Thunk u, so cool lesson!

  • @JasonElliott88
    @JasonElliott88 Před 2 lety

    Nice video Atila. Thanks

    • @AtilaDotIO
      @AtilaDotIO  Před 2 lety

      Glad you liked it!
      Thanks a bunch, Jason!

  • @JayeshBabuAV
    @JayeshBabuAV Před 5 měsíci

    hi Atila, thanks very much for this video. I have one query. Will this approach allow passing non-serializable data (eg, functions) to the runBigTask function ?

  • @mohammadbrzbrz72
    @mohammadbrzbrz72 Před 2 lety

    Thank you very much ❤️❤️❤️❤️❤️

  • @aleksejrozumnyj8170
    @aleksejrozumnyj8170 Před 2 lety

    Super cool video, but can anyone explain why the async function is blocking our thread like the sync one, I didn't catch it.

  • @Ryan-fe2du
    @Ryan-fe2du Před rokem

    I followed your setup but on my react app, when click the button it downloads the TypeScript file. Any idea why this is happening?

  • @Nick-tv5pu
    @Nick-tv5pu Před 2 lety +2

    Is there really no way to do this without ejecting?

  • @hevans900
    @hevans900 Před 2 lety

    I am struggling to get this to work with typescript using webpack 5 :(

  • @kostaskaldis9285
    @kostaskaldis9285 Před 2 lety

    what about redux and redux thunk? can u make a video how to implement it with these libraries?

  • @codingwithnipu
    @codingwithnipu Před rokem

    Please make a video for deep into webworker where should I need use and where no

  • @samfreshly8198
    @samfreshly8198 Před 3 lety

    Hey mate, does this work with webpack 5? Im having problems trying to set it up.

    • @SabrinaDias
      @SabrinaDias Před 2 lety +2

      const worker = new Worker(new URL("./worker", import.meta.url), { name: 'runBigTaskWorker', type: 'module'})

  • @Hiagoleof250
    @Hiagoleof250 Před 2 lety

    It does not work on build version

  • @mukeshra5299
    @mukeshra5299 Před rokem +2

    github repo link?

  • @FlavioZanoni
    @FlavioZanoni Před 2 lety

    Tu é BR?

  • @SabrinaDias
    @SabrinaDias Před 2 lety +2

    webpack5 =. const worker = new Worker(new URL("./worker", import.meta.url), { name: 'runBigTaskWorker', type: 'module'})