{
  "id": "@typed/fx#RefSubject.modify",
  "canonicalId": "@typed/fx/RefSubject#modify",
  "symbol": {
    "id": "@typed/fx#RefSubject.modify",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "RefSubject.modify",
    "kind": "constant",
    "signatures": [
      "export declare const modify: {\n    <A, B>(f: (value: A) => readonly [\n        B,\n        A\n    ]): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<B, E, R>;\n    <A, E, R, B>(ref: RefSubject<A, E, R>, f: (value: A) => readonly [\n        B,\n        A\n    ]): Effect.Effect<B, E, R>;\n};"
    ],
    "summary": "Modifies a `RefSubject` using a pure function that returns both a result and a new value.",
    "sections": {
      "Why": "Modifies a `RefSubject` using a pure function that returns both a result and a new value. The\ntransition is serialized at the RefSubject rather than coordinated by callers or UI components.",
      "Ownership and lifetime": "Running modify performs one serialized subject transition and resolves with its committed value.\nIt acquires no resource; failures and services remain those of the source ref."
    },
    "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  // Get the old value and increment, returning the old value\n  const oldValue = yield* RefSubject.modify(count, (value) => [value, value + 1] as const)\n\n  console.log(oldValue) // 5\n  const newValue = yield* count\n  console.log(newValue) // 6\n})"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/RefSubject/RefSubject.ts",
      "line": 2435
    },
    "since": "1.0.0",
    "category": "Transactions"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#RefSubject.modify",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.13",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "RefSubject",
    "qualifiedName": "RefSubject.modify",
    "declarationKey": "declaration:0583bb1296dcde4d2b926d5b",
    "family": "variable",
    "signatures": [
      "export declare const modify: {\n    <A, B>(f: (value: A) => readonly [\n        B,\n        A\n    ]): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<B, E, R>;\n    <A, E, R, B>(ref: RefSubject<A, E, R>, f: (value: A) => readonly [\n        B,\n        A\n    ]): Effect.Effect<B, E, R>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2435,
          "column": 14
        },
        "end": {
          "line": 2447,
          "column": 3
        }
      },
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2436,
          "column": 3
        },
        "end": {
          "line": 2438,
          "column": 65
        }
      },
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2439,
          "column": 3
        },
        "end": {
          "line": 2439,
          "column": 100
        }
      }
    ],
    "aliases": [
      "@typed/fx/RefSubject#modify"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#RefSubject",
    "static": false,
    "importedFrom": "declaration:0583bb1296dcde4d2b926d5b"
  },
  "declaration": {
    "declarationKey": "declaration:0583bb1296dcde4d2b926d5b",
    "name": "modify",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const modify: {\n    <A, B>(f: (value: A) => readonly [\n        B,\n        A\n    ]): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<B, E, R>;\n    <A, E, R, B>(ref: RefSubject<A, E, R>, f: (value: A) => readonly [\n        B,\n        A\n    ]): Effect.Effect<B, E, R>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/RefSubject/RefSubject.ts",
            "start": {
              "line": 2435,
              "column": 14
            },
            "end": {
              "line": 2447,
              "column": 3
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "<A, B>(f: (value: A) => readonly [\n    B,\n    A\n]): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<B, E, R>;",
          "<A, E, R, B>(ref: RefSubject<A, E, R>, f: (value: A) => readonly [\n    B,\n    A\n]): Effect.Effect<B, E, R>;"
        ],
        "typeParameters": [
          "A",
          "B",
          "E",
          "R"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/RefSubject/RefSubject.ts",
            "start": {
              "line": 2436,
              "column": 3
            },
            "end": {
              "line": 2438,
              "column": 65
            }
          },
          {
            "file": "packages/fx/src/RefSubject/RefSubject.ts",
            "start": {
              "line": 2439,
              "column": 3
            },
            "end": {
              "line": 2439,
              "column": 100
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const modify: {\n    <A, B>(f: (value: A) => readonly [\n        B,\n        A\n    ]): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<B, E, R>;\n    <A, E, R, B>(ref: RefSubject<A, E, R>, f: (value: A) => readonly [\n        B,\n        A\n    ]): Effect.Effect<B, E, R>;\n};"
    ],
    "typeParameters": [
      "A",
      "B",
      "E",
      "R"
    ],
    "summary": "Modifies a `RefSubject` using a pure function that returns both a result and a new value.",
    "sections": {
      "Why": "Modifies a `RefSubject` using a pure function that returns both a result and a new value. The\ntransition is serialized at the RefSubject rather than coordinated by callers or UI components.",
      "Ownership and lifetime": "Running modify performs one serialized subject transition and resolves with its committed value.\nIt acquires no resource; failures and services remain those of the source ref."
    },
    "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  // Get the old value and increment, returning the old value\n  const oldValue = yield* RefSubject.modify(count, (value) => [value, value + 1] as const)\n\n  console.log(oldValue) // 5\n  const newValue = yield* count\n  console.log(newValue) // 6\n})"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2435,
          "column": 14
        },
        "end": {
          "line": 2447,
          "column": 3
        }
      },
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2436,
          "column": 3
        },
        "end": {
          "line": 2438,
          "column": 65
        }
      },
      {
        "file": "packages/fx/src/RefSubject/RefSubject.ts",
        "start": {
          "line": 2439,
          "column": 3
        },
        "end": {
          "line": 2439,
          "column": 100
        }
      }
    ],
    "since": "1.0.0",
    "category": "Transactions"
  }
}
