postMessageToThread
fun postMessageToThread(threadId: Number, value: Any?, timeout: Number = definedExternally): Promise<Void>(source)
Sends a value to another worker, identified by its thread ID.
Since
v22.5.0
Parameters
threadId
The target thread ID. If the thread ID is invalid, a ERR_WORKER_MESSAGING_FAILED
error will be thrown. If the target thread ID is the current thread ID, a ERR_WORKER_MESSAGING_SAME_THREAD
error will be thrown.
value
The value to send.
transferList
If one or more MessagePort
-like objects are passed in value, a transferList
is required for those items or ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST
is thrown. See port.postMessage()
for more information.
timeout
Time to wait for the message to be delivered in milliseconds. By default it's undefined
, which means wait forever. If the operation times out, a ERR_WORKER_MESSAGING_TIMEOUT
error is thrown.
fun postMessageToThread(threadId: Number, value: Any?, transferList: ReadonlyArray<TransferListItem>, timeout: Number = definedExternally): Promise<Void>(source)