# suspend

```ts
function suspend(): Operation<void>
```

Indefinitely pause execution of the current operation. It is typically
used in conjunction with an [action](https://frontside.com/effection/api/v3/action.md) to mark the boundary
between setup and teardown.

```js
function onEvent(listener, name) {
  return action(function* (resolve) {
    try {
      listener.addEventListener(name, resolve);
      yield* suspend();
    } finally {
      listener.removeEventListener(name, resolve);
    }
  });
}
```

An operation will remain suspended until its enclosing scope is destroyed,
at which point it proceeds as though return had been called from the point
of suspension. Once an operation suspends once, further suspend operations
are ignored.

### Return Type


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


an operation that suspends the current operation

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