# run

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

Execute an operation.

Run is an entry point into Effection, and is especially useful when
embedding Effection code into existing code. However, If you are writing your
whole program using Effection, you should prefer [main](https://frontside.com/effection/api/v3/main.md).

### Examples
#### Example 1
```javascript
import { run, useAbortSignal } from 'effection';

async function fetchExample() {
  await run(function*() {
    let signal = yield* useAbortSignal();
    let response = yield* call(() => fetch('http://www.example.com', { signal }));
    yield* call(() => response.text());
  });
});
```

Run will create a new top-level scope for the operation. However, to run an
operation in an existing scope, you can use [Scope.run](https://frontside.com/effection/api/v3/Scope.md).

---
### Type Parameters
T


### Parameters


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


the operation to run
### Return Type


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


a task representing the running operation.

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