[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Types](https://evolu.dev/docs/api-reference/common/Types) › CallbackWithTeardown

```ts
type CallbackWithTeardown<T> = (value: T) => void | (() => void);
```

Defined in: [packages/common/src/Types.ts:38](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Types.ts#L38)

A function that receives a value and optionally returns a teardown function.

Use for subscriptions or callbacks that need abort-time teardown.

### Example

```ts
const subscribe: CallbackWithTeardown<EventSource> = (source) => {
  source.start();
  return () => source.stop();
};
```