# useScope

```ts
function* useScope(): Operation<Scope>
```

Get the scope of the currently running [Operation](https://frontside.com/effection/api/v4-next/Operation.md).

### Examples
#### Example 1
```ts
import { sleep, useScope } from "effection";

let scope = yield* useScope();
let task = yield* scope.spawn(function* () {
  yield* sleep(100);
  return "done";
});

// task is attached to the current scope and cannot outlive it
console.log(yield* task);
```

---
### Return Type


[Operation](https://frontside.com/effection/api/v4-next/Operation.md)&lt;[Scope](https://frontside.com/effection/api/v4-next/Scope.md)&gt;


an operation yielding the current scope

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