An example app that demonstrates full-duplex promise-based communication between the browser's main thread and a web worker, using worker-async, next.js, webpack, worker-loader, and typescript.
pages/index.js
: Entry point for the application. Callsexample.main.ts
below to initialize the worker and then makes remote RPC calls to the worker.workers/example.main.ts
: Initializes the worker from the main thread.workers/example.worker.ts
: Entry point for the worker thread.tsconfig.json
: Add typescript support to next.js.next.config.js
: Add web worker support to next.js.
Run npm run dev
to start the application in watch mode. After opening the page, you should see console logs from index.js showing the RPC requests and responses.
Run npm run build
and npm start