{
  "id": "@typed/fx/Fx#drainLayer",
  "canonicalId": "@typed/fx/Fx#drainLayer",
  "symbol": {
    "id": "@typed/fx/Fx#drainLayer",
    "packageName": "@typed/fx",
    "moduleName": "Fx",
    "exportName": "drainLayer",
    "kind": "constant",
    "signatures": [
      "export declare const drainLayer: <A, E, R>(fx: Fx<A, E, R>) => Layer<never, E, Exclude<R, Scope>>;"
    ],
    "summary": "Runs an `Fx` stream as a Layer.\nThe stream is forked in the background when the layer is acquired.",
    "sections": {
      "Why": "A background producer can share the same acquisition and shutdown boundary as an\napplication's Effect [Layer](https://effect.website/docs/v4/api/effect/Layer) graph\neven when it provides no service itself.",
      "Ownership and lifetime": "Building the Layer starts `drain(fx)` with `forkScoped`. Acquisition succeeds after\nthe fiber is registered; it does not wait for that fiber. The Layer scope interrupts\nthe fiber on release. A source failure is stored in the discarded child Fiber exit:\nit does not fail Layer acquisition and this API exposes no handle for awaiting it.\nRecover, report, or otherwise observe failures inside `fx` before calling\n`drainLayer`, or use `fork` when the caller needs the Fiber exit. The annotated `E`\nchannel remains in the public Layer type even though the background exit is not\npropagated by this implementation. `Scope` is supplied by the Layer."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { Fx } from \"@typed/fx\"\n\nconst reported = Fx.fail(\"offline\").pipe(\n  Fx.catch((error) => Fx.fromEffect(Effect.logError(error)))\n)\nconst Background = Fx.drainLayer(reported)\nconst program = Effect.void.pipe(Effect.provide(Background))"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/run/observe.ts",
      "line": 162
    },
    "since": "1.0.0",
    "category": "Running effects"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Fx#drainLayer",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": "Fx",
    "consumerSpecifier": "@typed/fx/Fx",
    "exportName": "drainLayer",
    "qualifiedName": "drainLayer",
    "declarationKey": "declaration:399e2407cfc59b5a5fe932a5",
    "family": "variable",
    "signatures": [
      "export declare const drainLayer: <A, E, R>(fx: Fx<A, E, R>) => Layer<never, E, Exclude<R, Scope>>;"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/run/observe.ts",
        "start": {
          "line": 162,
          "column": 14
        },
        "end": {
          "line": 163,
          "column": 39
        }
      }
    ],
    "aliases": [
      "@typed/fx#Fx.drainLayer"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:399e2407cfc59b5a5fe932a5",
    "name": "drainLayer",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const drainLayer: <A, E, R>(fx: Fx<A, E, R>) => Layer<never, E, Exclude<R, Scope>>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/run/observe.ts",
            "start": {
              "line": 162,
              "column": 14
            },
            "end": {
              "line": 163,
              "column": 39
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const drainLayer: <A, E, R>(fx: Fx<A, E, R>) => Layer<never, E, Exclude<R, Scope>>;"
    ],
    "typeParameters": [],
    "summary": "Runs an `Fx` stream as a Layer.\nThe stream is forked in the background when the layer is acquired.",
    "sections": {
      "Why": "A background producer can share the same acquisition and shutdown boundary as an\napplication's Effect [Layer](https://effect.website/docs/v4/api/effect/Layer) graph\neven when it provides no service itself.",
      "Ownership and lifetime": "Building the Layer starts `drain(fx)` with `forkScoped`. Acquisition succeeds after\nthe fiber is registered; it does not wait for that fiber. The Layer scope interrupts\nthe fiber on release. A source failure is stored in the discarded child Fiber exit:\nit does not fail Layer acquisition and this API exposes no handle for awaiting it.\nRecover, report, or otherwise observe failures inside `fx` before calling\n`drainLayer`, or use `fork` when the caller needs the Fiber exit. The annotated `E`\nchannel remains in the public Layer type even though the background exit is not\npropagated by this implementation. `Scope` is supplied by the Layer."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { Fx } from \"@typed/fx\"\n\nconst reported = Fx.fail(\"offline\").pipe(\n  Fx.catch((error) => Fx.fromEffect(Effect.logError(error)))\n)\nconst Background = Fx.drainLayer(reported)\nconst program = Effect.void.pipe(Effect.provide(Background))"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/run/observe.ts",
        "start": {
          "line": 162,
          "column": 14
        },
        "end": {
          "line": 163,
          "column": 39
        }
      }
    ],
    "since": "1.0.0",
    "category": "Running effects"
  }
}
