# call

```ts
function call<T, TArgs extends unknown[] = []>(fn: (…args: TArgs) => PromiseLike<T>): Operation<T>
```

Pause the current operation and evaluate an async function, plain
function, or operation function. The calling operation will be
resumed (or errored) once call is completed.

`call()` is a uniform integration point for calling async functions,
generator functions, and plain functions.

To call an async function:

### Examples
#### Example 1
```typescript
export function googleSlowly(query: string) {
   return call(async function() {
    await new Promise(resolve => setTimeout(resolve, 2000));
    return await fetch("https://google.com");
  });
}
```

or a plain function:

---
#### Example 2
```javascript
yield* call(() => "a string");
```

The function will be invoked anew every time that the `call()` operation is evaluated.

---
### Type Parameters
T


TArgs extends unknown&lbrack;&rbrack; = &lbrack;&rbrack;


### Parameters


**fn**: (...**args**:  TArgs) => PromiseLike&lt;T&gt;


the operation, promise, async function, generator function,
or plain function to call as part of this operation

### Return Type


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


an [Operation](https://frontside.com/effection/api/v4-next/Operation.md) that evaluates to the result of executing the function to completion

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

```ts
function call<T, TArgs extends unknown[] = []>(fn: (…args: TArgs) => Operation<T>): Operation<T>
```

### Type Parameters
T


TArgs extends unknown&lbrack;&rbrack; = &lbrack;&rbrack;


### Parameters


**fn**: (...**args**:  TArgs) => [Operation](https://frontside.com/effection/api/v4-next/Operation.md)&lt;T&gt;
### 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/call.ts#L74)

```ts
function call<T, TArgs extends unknown[] = []>(fn: (…args: TArgs) => T): Operation<T>
```

### Type Parameters
T


TArgs extends unknown&lbrack;&rbrack; = &lbrack;&rbrack;


### Parameters


**fn**: (...**args**:  TArgs) => 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/call.ts#L77)

```ts
function call<T, TArgs extends unknown[] = []>(callable: Callable<T, TArgs>, …args: TArgs): Operation<T>
```

### Type Parameters
T


TArgs extends unknown&lbrack;&rbrack; = &lbrack;&rbrack;


### Parameters


**callable**: [Callable](https://frontside.com/effection/api/v4-next/Callable.md)&lt;T, TArgs&gt;


...**args**:  TArgs
### 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/call.ts#L81)
