orabazu / sweet-web-workers

Dead simple example on how to use web workers with react with and without comlink ⚙️

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dead simple web workers ⚙️

This repo is bunch of dead simple examples on how to use web workers with react.

Screen Shot 2021-10-13 at 18 01 55

What's inside

There are two implementations vanilla and comlink. First one is vanilla JS approach while the latter one shows how to use it with TS in a more promise-like way.

1- Vanilla Web Worker 🚲

Use vanilla-step1 to practice, and vanilla-step2 to inspect implementation

Where is worker

👀 -> public/long-runner.js

2- Comlink and TS 🚗

Use comlink-step1 to practice, and comlink-step2 to inspect implementation

Where is worker

👀 -> src/workers/long-runner/long-runner.ts

How to start

yarn & yarn start

Useful links

About

Dead simple example on how to use web workers with react with and without comlink ⚙️


Languages

Language:TypeScript 43.3%Language:HTML 22.3%Language:SCSS 21.8%Language:JavaScript 7.8%Language:CSS 4.7%