import { Channel } from "https://deno.land/x/async_channels@v1.0.0-rc8/src/channel.ts";
Sends a value on the channel, and returns a promise that will be resolved when a the value is received (see
Channel.get
), or rejected if a provided AbortController
is aborted.
If the channel is closed, then the promise will be rejected with an InvalidTransitionError
.
import {Channel, InvalidTransitionError} from "./channel.ts"
const ch = new Channel()
ch.close();
try {
await ch.send("should fail")
console.assert(false, "unreachable")
} catch (e) {
console.assert(e instanceof InvalidTransitionError)
}
Parameters
optional
abortCtrl: AbortController