{
  "id": "@typed/fx#Push.switchMap",
  "canonicalId": "@typed/fx/Push#switchMap",
  "symbol": {
    "id": "@typed/fx#Push.switchMap",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "Push.switchMap",
    "kind": "constant",
    "signatures": [
      "export declare const switchMap: {\n    <B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;\n    <A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;\n};"
    ],
    "summary": "Transforms each output value into an inner `Fx`, observing only the latest one.\n\nA new outer value interrupts the previous inner fiber before starting the next.\nOutput cardinality is the cardinality of the successive active inners; values\nfrom an interrupted inner stop. Outer order determines replacement order, while\neach active inner preserves its own order. The input Sink is unchanged.",
    "sections": {
      "Why": "Latest-wins composition models search, navigation, and other work where a newer\nrequest makes the previous result irrelevant.",
      "Ownership and lifetime": "Running the result requires `Scope.Scope`. Each inner runs in that Scope and is\ninterrupted on replacement or outer interruption; the last inner is joined\nbefore normal completion. Outer and inner errors/services are combined."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport * as Fx from \"@typed/fx/Fx\"\nimport * as Push from \"@typed/fx/Push\"\nimport * as Sink from \"@typed/fx/Sink\"\n\nconst finalized: Array<number> = []\nconst outer = Fx.make<number>((sink) =>\n  sink.onSuccess(1).pipe(\n    Effect.andThen(Effect.sleep(\"5 millis\")),\n    Effect.andThen(sink.onSuccess(2))\n  )\n)\nconst push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), outer)\nconst switched = Push.switchMap(push, (id) =>\n  Fx.make<number>((sink) =>\n    Effect.gen(function* () {\n      yield* Effect.sleep(\"2 millis\")\n      yield* sink.onSuccess(id * 10 + 1)\n      yield* Effect.sleep(id === 1 ? \"20 millis\" : \"2 millis\")\n      yield* sink.onSuccess(id * 10 + 2)\n    }).pipe(Effect.ensuring(Effect.sync(() => finalized.push(id))))\n  )\n)\nconst program = Fx.collectAll(switched).pipe(\n  Effect.map((values) => ({ values, finalized })),\n  Effect.scoped\n)\n// Effect.runPromise(program) => { values: [11, 21, 22], finalized: [1, 2] }"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Push/Push.ts",
      "line": 1306
    },
    "since": "1.0.0",
    "category": "Concurrent output work"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#Push.switchMap",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "Push",
    "qualifiedName": "Push.switchMap",
    "declarationKey": "declaration:545b62393b097c16c5a502ee",
    "family": "variable",
    "signatures": [
      "export declare const switchMap: {\n    <B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;\n    <A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Push/Push.ts",
        "start": {
          "line": 1306,
          "column": 14
        },
        "end": {
          "line": 1335,
          "column": 3
        }
      },
      {
        "file": "packages/fx/src/Push/Push.ts",
        "start": {
          "line": 1307,
          "column": 3
        },
        "end": {
          "line": 1311,
          "column": 57
        }
      },
      {
        "file": "packages/fx/src/Push/Push.ts",
        "start": {
          "line": 1312,
          "column": 3
        },
        "end": {
          "line": 1315,
          "column": 55
        }
      }
    ],
    "aliases": [
      "@typed/fx/Push#switchMap"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#Push",
    "static": false,
    "importedFrom": "declaration:545b62393b097c16c5a502ee"
  },
  "declaration": {
    "declarationKey": "declaration:545b62393b097c16c5a502ee",
    "name": "switchMap",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const switchMap: {\n    <B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;\n    <A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Push/Push.ts",
            "start": {
              "line": 1306,
              "column": 14
            },
            "end": {
              "line": 1335,
              "column": 3
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "<B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;",
          "<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;"
        ],
        "typeParameters": [
          "B",
          "C",
          "E3",
          "R3",
          "A",
          "E",
          "R",
          "E2",
          "R2"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Push/Push.ts",
            "start": {
              "line": 1307,
              "column": 3
            },
            "end": {
              "line": 1311,
              "column": 57
            }
          },
          {
            "file": "packages/fx/src/Push/Push.ts",
            "start": {
              "line": 1312,
              "column": 3
            },
            "end": {
              "line": 1315,
              "column": 55
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const switchMap: {\n    <B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;\n    <A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;\n};"
    ],
    "typeParameters": [
      "B",
      "C",
      "E3",
      "R3",
      "A",
      "E",
      "R",
      "E2",
      "R2"
    ],
    "summary": "Transforms each output value into an inner `Fx`, observing only the latest one.\n\nA new outer value interrupts the previous inner fiber before starting the next.\nOutput cardinality is the cardinality of the successive active inners; values\nfrom an interrupted inner stop. Outer order determines replacement order, while\neach active inner preserves its own order. The input Sink is unchanged.",
    "sections": {
      "Why": "Latest-wins composition models search, navigation, and other work where a newer\nrequest makes the previous result irrelevant.",
      "Ownership and lifetime": "Running the result requires `Scope.Scope`. Each inner runs in that Scope and is\ninterrupted on replacement or outer interruption; the last inner is joined\nbefore normal completion. Outer and inner errors/services are combined."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport * as Fx from \"@typed/fx/Fx\"\nimport * as Push from \"@typed/fx/Push\"\nimport * as Sink from \"@typed/fx/Sink\"\n\nconst finalized: Array<number> = []\nconst outer = Fx.make<number>((sink) =>\n  sink.onSuccess(1).pipe(\n    Effect.andThen(Effect.sleep(\"5 millis\")),\n    Effect.andThen(sink.onSuccess(2))\n  )\n)\nconst push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), outer)\nconst switched = Push.switchMap(push, (id) =>\n  Fx.make<number>((sink) =>\n    Effect.gen(function* () {\n      yield* Effect.sleep(\"2 millis\")\n      yield* sink.onSuccess(id * 10 + 1)\n      yield* Effect.sleep(id === 1 ? \"20 millis\" : \"2 millis\")\n      yield* sink.onSuccess(id * 10 + 2)\n    }).pipe(Effect.ensuring(Effect.sync(() => finalized.push(id))))\n  )\n)\nconst program = Fx.collectAll(switched).pipe(\n  Effect.map((values) => ({ values, finalized })),\n  Effect.scoped\n)\n// Effect.runPromise(program) => { values: [11, 21, 22], finalized: [1, 2] }"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Push/Push.ts",
        "start": {
          "line": 1306,
          "column": 14
        },
        "end": {
          "line": 1335,
          "column": 3
        }
      },
      {
        "file": "packages/fx/src/Push/Push.ts",
        "start": {
          "line": 1307,
          "column": 3
        },
        "end": {
          "line": 1311,
          "column": 57
        }
      },
      {
        "file": "packages/fx/src/Push/Push.ts",
        "start": {
          "line": 1312,
          "column": 3
        },
        "end": {
          "line": 1315,
          "column": 55
        }
      }
    ],
    "since": "1.0.0",
    "category": "Concurrent output work"
  }
}
