# RefSubject.filterMap

Filters and transforms a `RefSubject`, `Computed`, or `Filtered` using a pure function that returns an `Option`.

## Signatures

```ts
export declare const filterMap: {
    <A, B>(f: (a: A) => Option.Option<B>): {
        <E, R>(ref: RefSubject<A, E, R> | Computed<A, E, R> | Filtered<A, E, R>): Filtered<B, E, R>;
        <R0, E0, B, E, R, E2, R2>(versioned: Versioned.Versioned<R0, E0, A, E, R, A, E2, R2>, f: (a: A) => Option.Option<B>): Filtered<B, E0 | E | E2, R0 | R2>;
    };
    <R0, E0, A, E, R, B, E2, R2>(versioned: Versioned.Versioned<R0, E0, A, E, R, A, E2, R2>, f: (a: A) => Option.Option<B>): Filtered<B, E0 | E | E2, R0 | R2 | Exclude<R, Scope.Scope>>;
    <A, E, R, B>(ref: RefSubject<A, E, R> | Computed<A, E, R> | Filtered<A, E, R>, f: (a: A) => Option.Option<B>): Filtered<B, E, R>;
};
```

## Why

Filters and transforms a `RefSubject`, `Computed`, or `Filtered` using a pure function that
returns an `Option`. Current reads and pushed versions use the same derivation, preventing
snapshot and subscription behavior from diverging.

## Ownership and lifetime

The filter map view retains no independent value. Its Effect read fails with NoSuchElement
while absent; the observing Scope owns and finalizes its Fx subscription.

## Examples

```ts
import { Effect, Option } from "effect"
import * as RefSubject from "@typed/fx/RefSubject"

const program = Effect.gen(function* () {
  const numbers = yield* RefSubject.make([1, 2, 3, 4, 5])

  // Get the first even number
  const firstEven = RefSubject.filterMap(numbers, (arr) =>
    Option.fromNullable(arr.find((n) => n % 2 === 0))
  )

  const value = yield* firstEven
  console.log(value) // 2
})
```
