# Fx.observeLayer

Observes the values of an `Fx` stream using a callback function and returns a `Layer`.
The callback can return `void` or an `Effect` which will be executed for each value.

## Signatures

```ts
export declare const observeLayer: {
    <A, E2 = never, R2 = never>(f: (value: A) => void | Effect<unknown, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Layer<never, E | E2, Exclude<R | R2, Scope>>;
    <A, E, R, E2 = never, R2 = never>(fx: Fx<A, E, R>, f: (value: A) => void | Effect<unknown, E2, R2>): Layer<never, E | E2, Exclude<R | R2, Scope>>;
};
```

## Why

Observation side effects can be installed as application infrastructure and share
the Layer graph's typed dependencies and shutdown behavior.

## Ownership and lifetime

Building the Layer forks `observe(fx, f)` in its scope and completes acquisition
after registration. Releasing the Layer interrupts the observer and source. Source
and callback failures terminate the discarded child Fiber; they do not fail Layer
acquisition, and this API exposes no Fiber handle from which to await the exit.
Handle or report those failures inside the source/callback, or use `observe`/`fork`
when the caller must observe them. The annotated `E | E2` Layer error remains in the
public type even though this implementation does not propagate the background exit.
`Scope` is supplied internally; delivery behavior remains that of `observe`.

## Examples

```ts
import { Effect } from "effect"
import { fromIterable, observeLayer } from "@typed/fx/Fx"

const report = (value: number) =>
  Effect.try({ try: () => JSON.stringify(BigInt(value)), catch: String }).pipe(
    Effect.catch((error) => Effect.logError(error))
  )
const LogValues = observeLayer(fromIterable([1, 2]), report)
const program = Effect.void.pipe(Effect.provide(LogValues))
```
