Propagate cancel on all readers
const rChannel = new ReadChannel();
// cancels the "string" channel.
rChannel.cancel.reader.string();
Propagate close on all writers of channel
const writer = new WriteChannel();
// closes the "string" channel.
writer.close.writer.string();
Readonly
readRead from a channel.
An example worker script:
// Setup the channel to be "string" (denoted by the type) with data of type string (denoted by data).
type MessageType = {type: "string", data: string};
const rChannel = new ReadChannel<MessageType>();
console.log(await rChannel.read.string())
Readonly
readRead everything from a channel.
An example worker script:
// Setup the channel to be "string" (denoted by the type) with data of type string (denoted by data).
type MessageType = {type: "string", data: string};
const rChannel = new ReadChannel<MessageType>();
// Read everything from the "string" channel.
for await (const item of rChannel.readAll.string()) {
console.log(item);
}
Connect the readFrom or writeTo worker/port to either recieve from or send to to a different message port.
The worker/port to send the connection
change to.
Whether you want to change the "writable" end or the "readable" end of the target
The connection that should now be written to or read from.
Generated using TypeDoc
Creates a readable channel.
Example
An example worker script: