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

Поделиться
HTML-код
  • Опубликовано: 15 апр 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 👋

Комментарии • 29

  • @Shakeel714
    @Shakeel714 3 года назад +6

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

  • @TeodorDimitrov1991
    @TeodorDimitrov1991 Год назад +2

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

  • @vadimk4310
    @vadimk4310 3 года назад

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

  • @fatahbe7667
    @fatahbe7667 11 месяцев назад +1

    Thanks Atila for the Video, very cool

  • @swyxTV
    @swyxTV 2 года назад +1

    awesome explanation and demo!

  • @sexrp2380
    @sexrp2380 3 года назад

    Good work! I learned a lot!

  • @painkiller2125
    @painkiller2125 3 года назад

    Thunk u, so cool lesson!

  • @Avee27119
    @Avee27119 2 года назад

    Nice work!!

  • @mohammadbrzbrz72
    @mohammadbrzbrz72 2 года назад

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

  • @xavierinthetube
    @xavierinthetube 3 года назад

    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.

  • @JasonElliott88
    @JasonElliott88 2 года назад

    Nice video Atila. Thanks

    • @AtilaDotIO
      @AtilaDotIO  2 года назад

      Glad you liked it!
      Thanks a bunch, Jason!

  • @aleksejrozumnyj8170
    @aleksejrozumnyj8170 2 года назад

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

  • @JayeshBabuAV
    @JayeshBabuAV 5 месяцев назад

    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 ?

  • @codingwithnipu
    @codingwithnipu Год назад

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

  • @Nick-tv5pu
    @Nick-tv5pu 2 года назад +2

    Is there really no way to do this without ejecting?

  • @kostaskaldis9285
    @kostaskaldis9285 2 года назад

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

  • @Ryan-fe2du
    @Ryan-fe2du Год назад

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

  • @hevans900
    @hevans900 2 года назад

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

  • @samfreshly8198
    @samfreshly8198 3 года назад

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

    • @SabrinaDias
      @SabrinaDias 2 года назад +2

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

  • @Hiagoleof250
    @Hiagoleof250 2 года назад

    It does not work on build version

  • @mukeshra5299
    @mukeshra5299 Год назад +2

    github repo link?

  • @FlavioZanoni
    @FlavioZanoni 2 года назад

    Tu é BR?

  • @SabrinaDias
    @SabrinaDias 2 года назад +2

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