{
  "id": "@typed/fx#Fx.ensuring",
  "canonicalId": "@typed/fx/Fx#ensuring",
  "symbol": {
    "id": "@typed/fx#Fx.ensuring",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "Fx.ensuring",
    "kind": "constant",
    "signatures": [
      "export declare const ensuring: {\n    <R2>(finalizer: Effect.Effect<void, never, R2>): <A, E, R>(self: Fx<A, E, R>) => Fx<A, E, R | R2>;\n    <A, E, R, R2>(self: Fx<A, E, R>, finalizer: Effect.Effect<void, never, R2>): Fx<A, E, R | R2>;\n};"
    ],
    "summary": "Runs a finalizer with no typed error after the Fx run ends for any reason.",
    "sections": {
      "Why": "Resources sometimes belong to the subscription as a whole rather than to\nindividual values. `ensuring` attaches unconditional teardown without\nchanging the source's success or typed-error channels.",
      "Ownership and lifetime": "The finalizer runs exactly once after normal completion, failure, defect, or\ninterruption of the source run and follows Effect's `ensuring` finalization\nsemantics. Its `never` typed-error channel does not make it incapable of\ndefecting or being interrupted: a finalizer defect can fail a successful run\nor combine with the source Cause. Its services are required for the subscription."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { ensuring } from \"@typed/fx/Fx\"\nimport { succeed } from \"@typed/fx/Fx\"\n\nconst observed = ensuring(succeed(\"ready\"), Effect.log(\"subscription closed\"))"
      },
      {
        "language": "text",
        "code": "A `never` typed-error channel can still contain a defect\n```ts\nimport { Effect } from \"effect\"\nimport { ensuring } from \"@typed/fx/Fx\"\nimport { succeed } from \"@typed/fx/Fx\"\n\nconst defectiveFinalizer = ensuring(succeed(\"ready\"), Effect.die(\"close failed\"))\n```"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/combinators/ensuring.ts",
      "line": 45
    },
    "since": "1.0.0",
    "category": "Resource lifetime"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#Fx.ensuring",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.13",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "Fx",
    "qualifiedName": "Fx.ensuring",
    "declarationKey": "declaration:04f34577b79ffd1e6d01664f",
    "family": "variable",
    "signatures": [
      "export declare const ensuring: {\n    <R2>(finalizer: Effect.Effect<void, never, R2>): <A, E, R>(self: Fx<A, E, R>) => Fx<A, E, R | R2>;\n    <A, E, R, R2>(self: Fx<A, E, R>, finalizer: Effect.Effect<void, never, R2>): Fx<A, E, R | R2>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/ensuring.ts",
        "start": {
          "line": 45,
          "column": 14
        },
        "end": {
          "line": 53,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/ensuring.ts",
        "start": {
          "line": 46,
          "column": 3
        },
        "end": {
          "line": 46,
          "column": 101
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/ensuring.ts",
        "start": {
          "line": 48,
          "column": 3
        },
        "end": {
          "line": 48,
          "column": 97
        }
      }
    ],
    "aliases": [
      "@typed/fx/Fx#ensuring"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#Fx",
    "static": false,
    "importedFrom": "declaration:04f34577b79ffd1e6d01664f"
  },
  "declaration": {
    "declarationKey": "declaration:04f34577b79ffd1e6d01664f",
    "name": "ensuring",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const ensuring: {\n    <R2>(finalizer: Effect.Effect<void, never, R2>): <A, E, R>(self: Fx<A, E, R>) => Fx<A, E, R | R2>;\n    <A, E, R, R2>(self: Fx<A, E, R>, finalizer: Effect.Effect<void, never, R2>): Fx<A, E, R | R2>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/ensuring.ts",
            "start": {
              "line": 45,
              "column": 14
            },
            "end": {
              "line": 53,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "<R2>(finalizer: Effect.Effect<void, never, R2>): <A, E, R>(self: Fx<A, E, R>) => Fx<A, E, R | R2>;",
          "<A, E, R, R2>(self: Fx<A, E, R>, finalizer: Effect.Effect<void, never, R2>): Fx<A, E, R | R2>;"
        ],
        "typeParameters": [
          "R2",
          "A",
          "E",
          "R"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/ensuring.ts",
            "start": {
              "line": 46,
              "column": 3
            },
            "end": {
              "line": 46,
              "column": 101
            }
          },
          {
            "file": "packages/fx/src/Fx/combinators/ensuring.ts",
            "start": {
              "line": 48,
              "column": 3
            },
            "end": {
              "line": 48,
              "column": 97
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const ensuring: {\n    <R2>(finalizer: Effect.Effect<void, never, R2>): <A, E, R>(self: Fx<A, E, R>) => Fx<A, E, R | R2>;\n    <A, E, R, R2>(self: Fx<A, E, R>, finalizer: Effect.Effect<void, never, R2>): Fx<A, E, R | R2>;\n};"
    ],
    "typeParameters": [
      "R2",
      "A",
      "E",
      "R"
    ],
    "summary": "Runs a finalizer with no typed error after the Fx run ends for any reason.",
    "sections": {
      "Why": "Resources sometimes belong to the subscription as a whole rather than to\nindividual values. `ensuring` attaches unconditional teardown without\nchanging the source's success or typed-error channels.",
      "Ownership and lifetime": "The finalizer runs exactly once after normal completion, failure, defect, or\ninterruption of the source run and follows Effect's `ensuring` finalization\nsemantics. Its `never` typed-error channel does not make it incapable of\ndefecting or being interrupted: a finalizer defect can fail a successful run\nor combine with the source Cause. Its services are required for the subscription."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { ensuring } from \"@typed/fx/Fx\"\nimport { succeed } from \"@typed/fx/Fx\"\n\nconst observed = ensuring(succeed(\"ready\"), Effect.log(\"subscription closed\"))"
      },
      {
        "language": "text",
        "code": "A `never` typed-error channel can still contain a defect\n```ts\nimport { Effect } from \"effect\"\nimport { ensuring } from \"@typed/fx/Fx\"\nimport { succeed } from \"@typed/fx/Fx\"\n\nconst defectiveFinalizer = ensuring(succeed(\"ready\"), Effect.die(\"close failed\"))\n```"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/ensuring.ts",
        "start": {
          "line": 45,
          "column": 14
        },
        "end": {
          "line": 53,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/ensuring.ts",
        "start": {
          "line": 46,
          "column": 3
        },
        "end": {
          "line": 46,
          "column": 101
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/ensuring.ts",
        "start": {
          "line": 48,
          "column": 3
        },
        "end": {
          "line": 48,
          "column": 97
        }
      }
    ],
    "since": "1.0.0",
    "category": "Resource lifetime"
  }
}
