# using

```ts
function* using<T extends Disposable | AsyncDisposable>(value: T): Operation<T>
```

Bind 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
```ts
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](https://frontside.com/effection/api/v4-next/Operation.md)&lt;T&gt;

[View code](https://github.com/thefrontside/effection/tree/effection-v4.2.0/lib/using.ts#L28)
