{
  "id": "@typed/fx/Fx#when",
  "canonicalId": "@typed/fx/Fx#when",
  "symbol": {
    "id": "@typed/fx/Fx#when",
    "packageName": "@typed/fx",
    "moduleName": "Fx",
    "exportName": "when",
    "kind": "constant",
    "signatures": [
      "export declare const when: <E, R, B, C>(condition: Fx<boolean, E, R>, matchers: {\n    onTrue: B;\n    onFalse: C;\n}) => Fx<B | C, E, R | Scope>;"
    ],
    "summary": "Conditionally emits one of two values based on the boolean value emitted by the condition stream.",
    "sections": {
      "Why": "`when` is the value-only form of `if`, implemented with `switchMap`. Each condition push selects a\nconstant inner Fx, but a newer condition can interrupt that inner before it emits; output\ncardinality can therefore be lower than the number of condition values.",
      "Ownership and lifetime": "It delegates branch switching to `if`; its constant branches acquire no resources. The Scope owns\nscheduled branch fibers, replacement awaits their interruption, and source completion waits for\nthe latest selected branch."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nconst program = Fx.collectAll(\n  Fx.when(Fx.fromIterable([true, false]), { onTrue: \"yes\", onFalse: \"no\" })\n) // the later `false` may replace `true` before \"yes\" is emitted"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/combinators/when.ts",
      "line": 90
    },
    "since": "1.0.0",
    "category": "Conditional sources"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Fx#when",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.13",
    "moduleName": "Fx",
    "consumerSpecifier": "@typed/fx/Fx",
    "exportName": "when",
    "qualifiedName": "when",
    "declarationKey": "declaration:74aa91b97f3505104c895bce",
    "family": "variable",
    "signatures": [
      "export declare const when: <E, R, B, C>(condition: Fx<boolean, E, R>, matchers: {\n    onTrue: B;\n    onFalse: C;\n}) => Fx<B | C, E, R | Scope>;"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/when.ts",
        "start": {
          "line": 90,
          "column": 14
        },
        "end": {
          "line": 98,
          "column": 2
        }
      }
    ],
    "aliases": [
      "@typed/fx#Fx.when"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:74aa91b97f3505104c895bce",
    "name": "when",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const when: <E, R, B, C>(condition: Fx<boolean, E, R>, matchers: {\n    onTrue: B;\n    onFalse: C;\n}) => Fx<B | C, E, R | Scope>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/when.ts",
            "start": {
              "line": 90,
              "column": 14
            },
            "end": {
              "line": 98,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const when: <E, R, B, C>(condition: Fx<boolean, E, R>, matchers: {\n    onTrue: B;\n    onFalse: C;\n}) => Fx<B | C, E, R | Scope>;"
    ],
    "typeParameters": [],
    "summary": "Conditionally emits one of two values based on the boolean value emitted by the condition stream.",
    "sections": {
      "Why": "`when` is the value-only form of `if`, implemented with `switchMap`. Each condition push selects a\nconstant inner Fx, but a newer condition can interrupt that inner before it emits; output\ncardinality can therefore be lower than the number of condition values.",
      "Ownership and lifetime": "It delegates branch switching to `if`; its constant branches acquire no resources. The Scope owns\nscheduled branch fibers, replacement awaits their interruption, and source completion waits for\nthe latest selected branch."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nconst program = Fx.collectAll(\n  Fx.when(Fx.fromIterable([true, false]), { onTrue: \"yes\", onFalse: \"no\" })\n) // the later `false` may replace `true` before \"yes\" is emitted"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/when.ts",
        "start": {
          "line": 90,
          "column": 14
        },
        "end": {
          "line": 98,
          "column": 2
        }
      }
    ],
    "since": "1.0.0",
    "category": "Conditional sources"
  }
}
