# Sink.collect

Collects all values into an array. Pass a `Ref<ReadonlyArray<A>>` (e.g. `Ref.make([])`);
after running, read the result with `Ref.get(ref)`.

## Signatures

```ts
export declare function collect<A, E>(ref: Ref.Ref<ReadonlyArray<A>>): Sink<A, E, never>;
```

## Why

Collection remains an explicit consumer concern and the accumulated result can be read without
changing the producer.

## Ownership and lifetime

The caller owns the Ref. Each success returns a lazy atomic `Ref.update` that allocates a new array.
Serialized producers collect in callback-Effect execution order. Concurrent updates remain atomic,
but execution scheduling—not invocation order—determines array order. Failures are ignored.

## Examples

```ts
import { Effect, Ref } from "effect"
import * as Sink from "@typed/fx/Sink"
const program = Effect.gen(function* () {
  const values = yield* Ref.make<ReadonlyArray<number>>([])
  return Sink.collect(values)
})
```
