Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/websocket_broadcastchannel/src/using.ts>using

Host-wide BroadcastChannel for Deno CLI, backed by WebSockets.
Latest
function using
import { using } from "https://deno.land/x/websocket_broadcastchannel@0.8.0/src/using.ts";

Similar to the TC39 proposal for using blocks, named Explicit Resource Management.

Give this a bunch of functions that each create a resource (resourceFactories), and a function that uses those resources (fn). It will call the resourceFactories, then pass their resources to fn. Then "finally" it will [Symbol.dispose]?.(), await [Symbol.asyncDispose]?.(), and await close?.() all the resources.

Type Parameters

T
R extends Resource
Rs extends R[] & { length: N; }
N extends number

Parameters

resourceFactories: ResourceFactory<R>[] & { length: N; }
fn: (resources: Rs) => T | Promise<T>

Returns

Promise<T>