# scoped

```ts
function scoped<T>(operation: () => Operation<T>): Operation<T>
```

Encapsulate an operation so that no effects will persist outside of
it. All active effects such as concurrent tasks and resources will be
shut down, and all contexts will be restored to their values outside
of the scope.

### Examples
#### Example 1
```js
import { useAbortSignal } from "effection";

function* example() {
  let signal = yield* scoped(function*() {
    return yield* useAbortSignal();
  });
  return signal.aborted; //=> true
}
```

---
### Type Parameters
T


### Parameters


**operation**: () => [Operation](https://frontside.com/effection/api/v3/Operation.md)&lt;T&gt;


the operation to be encapsulated

### Return Type


[Operation](https://frontside.com/effection/api/v3/Operation.md)&lt;T&gt;


the scoped operation

[View code](https://github.com/thefrontside/effection/tree/effection-v3.6.1/lib/scoped.ts#L26)
