{
  "id": "@typed/fx/Fx#race",
  "canonicalId": "@typed/fx/Fx#race",
  "symbol": {
    "id": "@typed/fx/Fx#race",
    "packageName": "@typed/fx",
    "moduleName": "Fx",
    "exportName": "race",
    "kind": "constant",
    "signatures": [
      "export declare const race: {\n    <AR, ER, RR>(that: Fx<AR, ER, RR>): <AL, EL, RL>(self: Fx<AL, EL, RL>) => Fx<AL | AR, EL | ER, RL | RR>;\n    <AL, EL, RL, AR, ER, RR>(self: Fx<AL, EL, RL>, that: Fx<AR, ER, RR>): Fx<AL | AR, EL | ER, RL | RR>;\n};"
    ],
    "summary": "Runs two streams concurrently until one emits, then mirrors the winner and\ninterrupts the other.\n\nA failure or completion from one side before the other emits does **not**\nwin unless every side ends without emitting. After a winner is chosen, that\nstream's later failures are propagated.",
    "sections": {
      "Why": "`race` selects a live producer by its first useful value rather than by setup,\ncompletion, or a fast failure. This is suitable for redundant sources where a\nproducer that ends silently should not prevent another from becoming useful.",
      "Selection, ordering, and cardinality": "Both inputs start concurrently. The first emitted value atomically selects its\nproducer; that value and all later values from the winner are forwarded in\norder. The loser emits nothing after selection and is interrupted. There is no\nbuffering or replay.",
      "Ownership and lifetime": "Before a winner, a non-interruption failure is remembered but does not win; it\nis reported only if both inputs end without a value. After selection, winner\nfailures are forwarded. Both environments remain required. The observing\nfiber owns both child fibers and interruption cancels the race and finalizers."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Effect } from \"effect\"\n\nconst response = Fx.race(\n  Fx.ensuring(Fx.at(\"slow\", \"50 millis\"), Effect.log(\"slow closed\")),\n  Fx.ensuring(Fx.at(\"fast\", \"5 millis\"), Effect.log(\"fast closed\"))\n)\nEffect.runPromise(Fx.collectAll(response)).then(console.log)\n// \"slow closed\" proves loser cleanup; the winning finalizer also runs\n// resolves [\"fast\"]"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/combinators/race.ts",
      "line": 58
    },
    "since": "1.0.0",
    "category": "Concurrent work"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Fx#race",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.13",
    "moduleName": "Fx",
    "consumerSpecifier": "@typed/fx/Fx",
    "exportName": "race",
    "qualifiedName": "race",
    "declarationKey": "declaration:5c27f806a052410429a436a2",
    "family": "variable",
    "signatures": [
      "export declare const race: {\n    <AR, ER, RR>(that: Fx<AR, ER, RR>): <AL, EL, RL>(self: Fx<AL, EL, RL>) => Fx<AL | AR, EL | ER, RL | RR>;\n    <AL, EL, RL, AR, ER, RR>(self: Fx<AL, EL, RL>, that: Fx<AR, ER, RR>): Fx<AL | AR, EL | ER, RL | RR>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/race.ts",
        "start": {
          "line": 58,
          "column": 14
        },
        "end": {
          "line": 70,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/race.ts",
        "start": {
          "line": 59,
          "column": 3
        },
        "end": {
          "line": 59,
          "column": 107
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/race.ts",
        "start": {
          "line": 60,
          "column": 3
        },
        "end": {
          "line": 63,
          "column": 36
        }
      }
    ],
    "aliases": [
      "@typed/fx#Fx.race"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:5c27f806a052410429a436a2",
    "name": "race",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const race: {\n    <AR, ER, RR>(that: Fx<AR, ER, RR>): <AL, EL, RL>(self: Fx<AL, EL, RL>) => Fx<AL | AR, EL | ER, RL | RR>;\n    <AL, EL, RL, AR, ER, RR>(self: Fx<AL, EL, RL>, that: Fx<AR, ER, RR>): Fx<AL | AR, EL | ER, RL | RR>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/race.ts",
            "start": {
              "line": 58,
              "column": 14
            },
            "end": {
              "line": 70,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "<AR, ER, RR>(that: Fx<AR, ER, RR>): <AL, EL, RL>(self: Fx<AL, EL, RL>) => Fx<AL | AR, EL | ER, RL | RR>;",
          "<AL, EL, RL, AR, ER, RR>(self: Fx<AL, EL, RL>, that: Fx<AR, ER, RR>): Fx<AL | AR, EL | ER, RL | RR>;"
        ],
        "typeParameters": [
          "AR",
          "ER",
          "RR",
          "AL",
          "EL",
          "RL"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/race.ts",
            "start": {
              "line": 59,
              "column": 3
            },
            "end": {
              "line": 59,
              "column": 107
            }
          },
          {
            "file": "packages/fx/src/Fx/combinators/race.ts",
            "start": {
              "line": 60,
              "column": 3
            },
            "end": {
              "line": 63,
              "column": 36
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const race: {\n    <AR, ER, RR>(that: Fx<AR, ER, RR>): <AL, EL, RL>(self: Fx<AL, EL, RL>) => Fx<AL | AR, EL | ER, RL | RR>;\n    <AL, EL, RL, AR, ER, RR>(self: Fx<AL, EL, RL>, that: Fx<AR, ER, RR>): Fx<AL | AR, EL | ER, RL | RR>;\n};"
    ],
    "typeParameters": [
      "AR",
      "ER",
      "RR",
      "AL",
      "EL",
      "RL"
    ],
    "summary": "Runs two streams concurrently until one emits, then mirrors the winner and\ninterrupts the other.\n\nA failure or completion from one side before the other emits does **not**\nwin unless every side ends without emitting. After a winner is chosen, that\nstream's later failures are propagated.",
    "sections": {
      "Why": "`race` selects a live producer by its first useful value rather than by setup,\ncompletion, or a fast failure. This is suitable for redundant sources where a\nproducer that ends silently should not prevent another from becoming useful.",
      "Selection, ordering, and cardinality": "Both inputs start concurrently. The first emitted value atomically selects its\nproducer; that value and all later values from the winner are forwarded in\norder. The loser emits nothing after selection and is interrupted. There is no\nbuffering or replay.",
      "Ownership and lifetime": "Before a winner, a non-interruption failure is remembered but does not win; it\nis reported only if both inputs end without a value. After selection, winner\nfailures are forwarded. Both environments remain required. The observing\nfiber owns both child fibers and interruption cancels the race and finalizers."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Effect } from \"effect\"\n\nconst response = Fx.race(\n  Fx.ensuring(Fx.at(\"slow\", \"50 millis\"), Effect.log(\"slow closed\")),\n  Fx.ensuring(Fx.at(\"fast\", \"5 millis\"), Effect.log(\"fast closed\"))\n)\nEffect.runPromise(Fx.collectAll(response)).then(console.log)\n// \"slow closed\" proves loser cleanup; the winning finalizer also runs\n// resolves [\"fast\"]"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/race.ts",
        "start": {
          "line": 58,
          "column": 14
        },
        "end": {
          "line": 70,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/race.ts",
        "start": {
          "line": 59,
          "column": 3
        },
        "end": {
          "line": 59,
          "column": 107
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/race.ts",
        "start": {
          "line": 60,
          "column": 3
        },
        "end": {
          "line": 63,
          "column": 36
        }
      }
    ],
    "since": "1.0.0",
    "category": "Concurrent work"
  }
}
