tezvyn:

Worker postMessage: The Structured Clone Pipe

Source: developer.mozilla.orgintermediate

Worker postMessage moves data between threads via structured cloning. Use it to offload heavy work without blocking the UI. The message argument is mandatory, so omitting it is an error and you must pass null when there is no data.

Worker postMessage is the pipe that moves JavaScript objects between the main thread and a worker via structured cloning. Use it to offload heavy computation or parse large files without freezing the UI. The message parameter is mandatory, so omitting it is invalid and you must explicitly pass null when there is no payload. You can only send one object per call, so bundling values into an array is common, and you can transfer ArrayBuffer ownership so the sender loses access.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Worker postMessage: The Structured Clone Pipe · Tezvyn