function using
thefrontside/effectionBind a JavaScript disposable value to the current Effection scope.
The provided value is yielded immediately, then disposed when the owning scope exits (on return, error, or halt).
Examples
Example 1
import { run, using } from "effection";
class Connection {
opened = true;
[Symbol.dispose]() {
this.opened = false;
}
}
await run(function* () {
let connection = yield* using(new Connection());
connection.opened; // true while in scope
});
Type Parameters
T extends Disposable | AsyncDisposable
Parameters
value: T
Return Type
Operation<T>