# modifyEffect

Modifies a `RefSubject` using an `Effect`ful function that returns both a result and a new value.

## Signatures

```ts
export declare const modifyEffect: {
    <A, B, E2, R2>(f: (value: A) => Effect.Effect<readonly [
        B,
        A
    ], E2, R2>): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<B, E | E2, R | R2>;
    <A, E, R, B, E2, R2>(ref: RefSubject<A, E, R>, f: (value: A) => Effect.Effect<readonly [
        B,
        A
    ], E2, R2>): Effect.Effect<B, E | E2, R | R2>;
};
```

## Why

Modifies a `RefSubject` using an `Effect`ful function that returns both a result and a new
value. The transition is serialized at the RefSubject rather than coordinated by callers or UI
components.

## Ownership and lifetime

Running modify effect performs one serialized subject transition and resolves with its committed
value. It acquires no resource; failures and services remain those of the source ref.

## Examples

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

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

  // Get the old value and set a new one, returning the old value
  const oldValue = yield* RefSubject.modifyEffect(count, (value) =>
    Effect.succeed([value, value + 10] as const)
  )

  console.log(oldValue) // 5
  const newValue = yield* count
  console.log(newValue) // 15
})
```
