{
  "id": "@typed/fx#RefSubject.update",
  "canonicalId": "@typed/fx/RefSubject#update",
  "symbol": {
    "id": "@typed/fx#RefSubject.update",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "RefSubject.update",
    "kind": "constant",
    "signatures": [
      "export declare const update: {\n    <A>(f: (value: A) => A): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E, R>;\n    <A, E, R>(ref: RefSubject<A, E, R>, f: (value: A) => A): Effect.Effect<A, E, R>;\n};"
    ],
    "summary": "Updates a `RefSubject` using a pure function.",
    "sections": {
      "Why": "`update` expresses a state transition where the state lives, without moving\ntransition logic into a component or renderer. The same function can run in\napplication code, tests, workers, event handlers, or a Typed template.",
      "Ownership and lifetime": "The update runs inside the RefSubject's existing synchronized update\nboundary: it reads the committed value, derives the next value, commits it,\nand publishes that change. It acquires no independent resource and retains\nthe subject's existing error and service channels.",
      "Concurrency and failure": "Concurrent updates are serialized by the subject core so each function sees\na committed value. A pure updater adds no error channel; failures already\nassociated with reading or writing the RefSubject remain explicit in `E`."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport * as RefSubject from \"@typed/fx/RefSubject\"\n\nconst program = Effect.gen(function* () {\n  const count = yield* RefSubject.make(5)\n\n  // Increment by 1\n  yield* RefSubject.update(count, (n) => n + 1)\n  const value = yield* count\n  console.log(value) // 6\n\n  // Can also use pipe syntax\n  yield* count.pipe(RefSubject.update((n) => n * 2))\n  const doubled = yield* count\n  console.log(doubled) // 12\n})"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/RefSubject/RefSubject.ts",
      "line": 2329
    },
    "since": "1.0.0",
    "category": "State updates"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#RefSubject.update",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "RefSubject",
    "qualifiedName": "RefSubject.update",
    "declarationKey": "declaration:e4ac3f71a6cfd62ddf0672fe",
    "family": "variable",
    "signatures": [
      "export declare const update: {\n    <A>(f: (value: A) => A): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E, R>;\n    <A, E, R>(ref: RefSubject<A, E, R>, f: (value: A) => A): Effect.Effect<A, E, R>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2329,
          "column": 14
        },
        "end": {
          "line": 2334,
          "column": 3
        }
      },
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2330,
          "column": 3
        },
        "end": {
          "line": 2330,
          "column": 87
        }
      },
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2331,
          "column": 3
        },
        "end": {
          "line": 2331,
          "column": 83
        }
      }
    ],
    "aliases": [
      "@typed/fx/RefSubject#update"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#RefSubject",
    "static": false,
    "importedFrom": "declaration:e4ac3f71a6cfd62ddf0672fe"
  },
  "declaration": {
    "declarationKey": "declaration:e4ac3f71a6cfd62ddf0672fe",
    "name": "update",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const update: {\n    <A>(f: (value: A) => A): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E, R>;\n    <A, E, R>(ref: RefSubject<A, E, R>, f: (value: A) => A): Effect.Effect<A, E, R>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/RefSubject/RefSubject.ts",
            "start": {
              "line": 2329,
              "column": 14
            },
            "end": {
              "line": 2334,
              "column": 3
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "<A>(f: (value: A) => A): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E, R>;",
          "<A, E, R>(ref: RefSubject<A, E, R>, f: (value: A) => A): Effect.Effect<A, E, R>;"
        ],
        "typeParameters": [
          "A",
          "E",
          "R"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/RefSubject/RefSubject.ts",
            "start": {
              "line": 2330,
              "column": 3
            },
            "end": {
              "line": 2330,
              "column": 87
            }
          },
          {
            "file": "packages/fx/src/RefSubject/RefSubject.ts",
            "start": {
              "line": 2331,
              "column": 3
            },
            "end": {
              "line": 2331,
              "column": 83
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const update: {\n    <A>(f: (value: A) => A): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E, R>;\n    <A, E, R>(ref: RefSubject<A, E, R>, f: (value: A) => A): Effect.Effect<A, E, R>;\n};"
    ],
    "typeParameters": [
      "A",
      "E",
      "R"
    ],
    "summary": "Updates a `RefSubject` using a pure function.",
    "sections": {
      "Why": "`update` expresses a state transition where the state lives, without moving\ntransition logic into a component or renderer. The same function can run in\napplication code, tests, workers, event handlers, or a Typed template.",
      "Ownership and lifetime": "The update runs inside the RefSubject's existing synchronized update\nboundary: it reads the committed value, derives the next value, commits it,\nand publishes that change. It acquires no independent resource and retains\nthe subject's existing error and service channels.",
      "Concurrency and failure": "Concurrent updates are serialized by the subject core so each function sees\na committed value. A pure updater adds no error channel; failures already\nassociated with reading or writing the RefSubject remain explicit in `E`."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport * as RefSubject from \"@typed/fx/RefSubject\"\n\nconst program = Effect.gen(function* () {\n  const count = yield* RefSubject.make(5)\n\n  // Increment by 1\n  yield* RefSubject.update(count, (n) => n + 1)\n  const value = yield* count\n  console.log(value) // 6\n\n  // Can also use pipe syntax\n  yield* count.pipe(RefSubject.update((n) => n * 2))\n  const doubled = yield* count\n  console.log(doubled) // 12\n})"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2329,
          "column": 14
        },
        "end": {
          "line": 2334,
          "column": 3
        }
      },
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2330,
          "column": 3
        },
        "end": {
          "line": 2330,
          "column": 87
        }
      },
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2331,
          "column": 3
        },
        "end": {
          "line": 2331,
          "column": 83
        }
      }
    ],
    "since": "1.0.0",
    "category": "State updates"
  }
}
