# toStream

Adapts a push-based `Fx` to an Effect `Stream`.

## Signatures

```ts
export declare const toStream: <A, E, R>(fx: Fx.Fx<A, E, R>, options?: ToStreamOptions) => Stream.Stream<A, E, R>;
```

## Why

Existing Effect [Stream](https://effect.website/docs/v4/api/effect/Stream) consumers
can use an `Fx` without losing the producer's typed values, failures, or services.
Values and causes cross a queue in emission order; the queue ends when the `Fx` run
completes.

## Ownership and lifetime

Conversion is lazy. Running the Stream allocates the callback queue and runs the
`Fx`; the Stream's scope owns both. Interruption closes the callback subscription
through Effect Stream's lifecycle. Buffering follows `options`.

## Examples

```ts
import { Stream } from "effect"
import { fromIterable, toStream } from "@typed/fx/Fx"

const values = toStream(fromIterable([1, 2, 3]))
const total = Stream.runFold(values, () => 0, (sum, value) => sum + value)
```
