{
  "id": "@typed/fx/Fx#observe",
  "canonicalId": "@typed/fx/Fx#observe",
  "symbol": {
    "id": "@typed/fx/Fx#observe",
    "packageName": "@typed/fx",
    "moduleName": "Fx",
    "exportName": "observe",
    "kind": "constant",
    "signatures": [
      "export declare const observe: {\n    <A, E2 = never, R2 = never>(f: (value: A) => void | Effect<unknown, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Effect<unknown, E | E2, R | R2>;\n    <A, E, R, E2 = never, R2 = never>(fx: Fx<A, E, R>, f: (value: A) => void | Effect<unknown, E2, R2>): Effect<unknown, E | E2, R | R2>;\n};"
    ],
    "summary": "Observes the values of an `Fx` stream using a callback function.\nThe callback can return `void` or an `Effect` which will be executed for each value.",
    "sections": {
      "Why": "`observe` is the primary Effect boundary for performing work for each pushed value.\nA plain callback is lifted to Effect, while an Effect callback contributes its own\ntyped failures and services to the result.",
      "Ownership and lifetime": "Observation starts only when the returned Effect runs. That Effect owns the source\nrun and completes when the source completes. Interruption interrupts the internal\nfiber and source cleanup. Callback invocation follows the producer's delivery\nbehavior; `observe` adds no buffer or concurrency of its own. A source cause or a\ncallback failure fails the returned Effect as `E | E2`."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect, Ref } from \"effect\"\nimport { fromIterable, observe } from \"@typed/fx/Fx\"\n\nconst program = Effect.gen(function* () {\n  const total = yield* Ref.make(0)\n  yield* observe(fromIterable([1, 2, 3]), (value) => Ref.update(total, (n) => n + value))\n  return yield* Ref.get(total)\n})"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/run/observe.ts",
      "line": 60
    },
    "since": "1.0.0",
    "category": "Running effects"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Fx#observe",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": "Fx",
    "consumerSpecifier": "@typed/fx/Fx",
    "exportName": "observe",
    "qualifiedName": "observe",
    "declarationKey": "declaration:210e940c3ee85c092e2c1cab",
    "family": "variable",
    "signatures": [
      "export declare const observe: {\n    <A, E2 = never, R2 = never>(f: (value: A) => void | Effect<unknown, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Effect<unknown, E | E2, R | R2>;\n    <A, E, R, E2 = never, R2 = never>(fx: Fx<A, E, R>, f: (value: A) => void | Effect<unknown, E2, R2>): Effect<unknown, E | E2, R | R2>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/run/observe.ts",
        "start": {
          "line": 60,
          "column": 14
        },
        "end": {
          "line": 91,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/run/observe.ts",
        "start": {
          "line": 61,
          "column": 3
        },
        "end": {
          "line": 63,
          "column": 65
        }
      },
      {
        "file": "packages/fx/src/Fx/run/observe.ts",
        "start": {
          "line": 65,
          "column": 3
        },
        "end": {
          "line": 68,
          "column": 38
        }
      }
    ],
    "aliases": [
      "@typed/fx#Fx.observe"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:210e940c3ee85c092e2c1cab",
    "name": "observe",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const observe: {\n    <A, E2 = never, R2 = never>(f: (value: A) => void | Effect<unknown, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Effect<unknown, E | E2, R | R2>;\n    <A, E, R, E2 = never, R2 = never>(fx: Fx<A, E, R>, f: (value: A) => void | Effect<unknown, E2, R2>): Effect<unknown, E | E2, R | R2>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/run/observe.ts",
            "start": {
              "line": 60,
              "column": 14
            },
            "end": {
              "line": 91,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "<A, E2 = never, R2 = never>(f: (value: A) => void | Effect<unknown, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Effect<unknown, E | E2, R | R2>;",
          "<A, E, R, E2 = never, R2 = never>(fx: Fx<A, E, R>, f: (value: A) => void | Effect<unknown, E2, R2>): Effect<unknown, E | E2, R | R2>;"
        ],
        "typeParameters": [
          "A",
          "E2 = never",
          "R2 = never",
          "E",
          "R"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/run/observe.ts",
            "start": {
              "line": 61,
              "column": 3
            },
            "end": {
              "line": 63,
              "column": 65
            }
          },
          {
            "file": "packages/fx/src/Fx/run/observe.ts",
            "start": {
              "line": 65,
              "column": 3
            },
            "end": {
              "line": 68,
              "column": 38
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const observe: {\n    <A, E2 = never, R2 = never>(f: (value: A) => void | Effect<unknown, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Effect<unknown, E | E2, R | R2>;\n    <A, E, R, E2 = never, R2 = never>(fx: Fx<A, E, R>, f: (value: A) => void | Effect<unknown, E2, R2>): Effect<unknown, E | E2, R | R2>;\n};"
    ],
    "typeParameters": [
      "A",
      "E2 = never",
      "R2 = never",
      "E",
      "R"
    ],
    "summary": "Observes the values of an `Fx` stream using a callback function.\nThe callback can return `void` or an `Effect` which will be executed for each value.",
    "sections": {
      "Why": "`observe` is the primary Effect boundary for performing work for each pushed value.\nA plain callback is lifted to Effect, while an Effect callback contributes its own\ntyped failures and services to the result.",
      "Ownership and lifetime": "Observation starts only when the returned Effect runs. That Effect owns the source\nrun and completes when the source completes. Interruption interrupts the internal\nfiber and source cleanup. Callback invocation follows the producer's delivery\nbehavior; `observe` adds no buffer or concurrency of its own. A source cause or a\ncallback failure fails the returned Effect as `E | E2`."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect, Ref } from \"effect\"\nimport { fromIterable, observe } from \"@typed/fx/Fx\"\n\nconst program = Effect.gen(function* () {\n  const total = yield* Ref.make(0)\n  yield* observe(fromIterable([1, 2, 3]), (value) => Ref.update(total, (n) => n + value))\n  return yield* Ref.get(total)\n})"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/run/observe.ts",
        "start": {
          "line": 60,
          "column": 14
        },
        "end": {
          "line": 91,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/run/observe.ts",
        "start": {
          "line": 61,
          "column": 3
        },
        "end": {
          "line": 63,
          "column": 65
        }
      },
      {
        "file": "packages/fx/src/Fx/run/observe.ts",
        "start": {
          "line": 65,
          "column": 3
        },
        "end": {
          "line": 68,
          "column": 38
        }
      }
    ],
    "since": "1.0.0",
    "category": "Running effects"
  }
}
