Open kekekeks opened 7 months ago
It would be good to be able to postMessage between UI thread and any JSWebWorker
in both directions.
Also to subscribe to event handler. For that I think we would be better off if we modeled the API in the same way as
postMessage
and onMessage
. For that we need to somehow pass the identity of the JSWebWorker
to the main thread. At the moment the draft of the JSWebWorker
API doesn't offer such identity or channel.
Background and motivation
Certain javascript objects are intended to be transferred to web worker scope rather than be just copied. Notable examples are OffscreenCanvas, streams, video frames, webrtc, etc.
API Proposal
API Usage
Alternative Designs
Provide a way to add handlers to custom messages for
message
event andpostMessage
API ofWorker
/DedicatedWorkerGlobalScope
objects@pavelsavara