# RefSubject.transform

Transforms a `RefSubject` invariantly using bidirectional mapping functions.

## Signatures

```ts
export declare const transform: {
    <A, B>(toB: (a: A) => B, toA: (b: B) => A): <E, R>(ref: RefSubject<A, E, R>) => RefSubject<B, E, R>;
    <A, E, R, B>(ref: RefSubject<A, E, R>, toB: (a: A) => B, toA: (b: B) => A): RefSubject<B, E, R>;
};
```

## Why

Creates a bidirectional lens over state: reads map outward and writes map back to the original
RefSubject without allocating a second store.

## Ownership and lifetime

The derived ref owns no independent state or subscription. It follows the source lifetime and
routes writes through the source's synchronized update boundary.

## Examples

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

const program = Effect.gen(function* () {
  const count = yield* RefSubject.make(5)

  // Transform to string and back
  const countStr = RefSubject.transform(
    count,
    (n) => n.toString(),
    (s) => parseInt(s, 10)
  )

  const value = yield* countStr
  console.log(value) // "5"

  // Set using the transformed type
  yield* RefSubject.set(countStr, "10")

  // Original reflects the change
  const original = yield* count
  console.log(original) // 10
})
```
