I'm confused as to how to send JSON data back from a webworker to the main thread via an Array Buffer.
suppose:
data = {"key":"value"}
worker.postMessage(data, buffers);
what exactly am I supposed to put in for buffers?
I'm confused as to how to send JSON data back from a webworker to the main thread via an Array Buffer.
suppose:
data = {"key":"value"}
worker.postMessage(data, buffers);
what exactly am I supposed to put in for buffers?
.postMessage accepts a message identifier and the message data like this:
var message_data = {'key':'val'};
worker.postMessage('my_message', message_data);
message identifier in a sense signifies the type of message or event sent, then the data are the actual message data or parameters, which can include any JS transferable type (including Typed Arrays)