{
  "id": "@typed/fx#Fx.flatMapConcurrently",
  "canonicalId": "@typed/fx/Fx#flatMapConcurrently",
  "symbol": {
    "id": "@typed/fx#Fx.flatMapConcurrently",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "Fx.flatMapConcurrently",
    "kind": "constant",
    "signatures": [
      "export declare const flatMapConcurrently: {\n    <A, B, E2, R2>(f: (a: A) => Fx<B, E2, R2>, concurrency: number): <E, R>(self: Fx<A, E, R>) => Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;\n    <A, E, R, B, E2, R2>(self: Fx<A, E, R>, f: (a: A) => Fx<B, E2, R2>, concurrency: number): Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;\n};"
    ],
    "summary": "Maps each element of an Fx to a new Fx, running them concurrently with a limit.",
    "sections": {
      "Why": "This is the admission-controlled form of {@link flatMap }. It bounds active\nwork while retaining every source value, which is appropriate when a remote\nservice or local resource has a known concurrency budget.",
      "Concurrency, ordering, and buffering": "Each source value creates one child fiber. A semaphore admits at most\n`concurrency` inners into execution; excess fibers wait for a permit rather\nthan being dropped. Values from each inner retain local order, but admitted\ninners may interleave and output is not reordered into source order.",
      "Ownership and lifetime": "A non-positive, fractional, infinite, or unsafe-integer limit fails through\nthe Sink with `Cause.IllegalArgumentError`. Source and inner failures and\nservices remain typed. The required `Scope` owns waiting and active fibers;\nsource completion waits for all of them, and interruption cancels both groups\nand runs active inner finalizers."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Effect } from \"effect\"\n\nconst jobs = Fx.fromIterable([\n  { id: \"one\", wait: \"20 millis\" as const },\n  { id: \"two\", wait: \"20 millis\" as const },\n  { id: \"three\", wait: \"1 millis\" as const }\n])\nconst bounded = Fx.flatMapConcurrently(\n  jobs,\n  ({ id, wait }) => Fx.at(id, wait),\n  2\n)\n\nEffect.runPromise(Effect.scoped(Fx.collectAll(bounded))).then(console.log)\n// \"three\" waits for one of the first two permits despite its shorter delay"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
      "line": 63
    },
    "since": "1.0.0",
    "category": "Concurrent work"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#Fx.flatMapConcurrently",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "Fx",
    "qualifiedName": "Fx.flatMapConcurrently",
    "declarationKey": "declaration:59a386e81a95b441cbd1d12c",
    "family": "variable",
    "signatures": [
      "export declare const flatMapConcurrently: {\n    <A, B, E2, R2>(f: (a: A) => Fx<B, E2, R2>, concurrency: number): <E, R>(self: Fx<A, E, R>) => Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;\n    <A, E, R, B, E2, R2>(self: Fx<A, E, R>, f: (a: A) => Fx<B, E2, R2>, concurrency: number): Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
        "start": {
          "line": 63,
          "column": 14
        },
        "end": {
          "line": 101,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
        "start": {
          "line": 64,
          "column": 3
        },
        "end": {
          "line": 67,
          "column": 100
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
        "start": {
          "line": 69,
          "column": 3
        },
        "end": {
          "line": 73,
          "column": 71
        }
      }
    ],
    "aliases": [
      "@typed/fx/Fx#flatMapConcurrently"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#Fx",
    "static": false,
    "importedFrom": "declaration:59a386e81a95b441cbd1d12c"
  },
  "declaration": {
    "declarationKey": "declaration:59a386e81a95b441cbd1d12c",
    "name": "flatMapConcurrently",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const flatMapConcurrently: {\n    <A, B, E2, R2>(f: (a: A) => Fx<B, E2, R2>, concurrency: number): <E, R>(self: Fx<A, E, R>) => Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;\n    <A, E, R, B, E2, R2>(self: Fx<A, E, R>, f: (a: A) => Fx<B, E2, R2>, concurrency: number): Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
            "start": {
              "line": 63,
              "column": 14
            },
            "end": {
              "line": 101,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "<A, B, E2, R2>(f: (a: A) => Fx<B, E2, R2>, concurrency: number): <E, R>(self: Fx<A, E, R>) => Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;",
          "<A, E, R, B, E2, R2>(self: Fx<A, E, R>, f: (a: A) => Fx<B, E2, R2>, concurrency: number): Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;"
        ],
        "typeParameters": [
          "A",
          "B",
          "E2",
          "R2",
          "E",
          "R"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
            "start": {
              "line": 64,
              "column": 3
            },
            "end": {
              "line": 67,
              "column": 100
            }
          },
          {
            "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
            "start": {
              "line": 69,
              "column": 3
            },
            "end": {
              "line": 73,
              "column": 71
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const flatMapConcurrently: {\n    <A, B, E2, R2>(f: (a: A) => Fx<B, E2, R2>, concurrency: number): <E, R>(self: Fx<A, E, R>) => Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;\n    <A, E, R, B, E2, R2>(self: Fx<A, E, R>, f: (a: A) => Fx<B, E2, R2>, concurrency: number): Fx<B, E | E2 | Cause.IllegalArgumentError, R | R2 | Scope.Scope>;\n};"
    ],
    "typeParameters": [
      "A",
      "B",
      "E2",
      "R2",
      "E",
      "R"
    ],
    "summary": "Maps each element of an Fx to a new Fx, running them concurrently with a limit.",
    "sections": {
      "Why": "This is the admission-controlled form of {@link flatMap }. It bounds active\nwork while retaining every source value, which is appropriate when a remote\nservice or local resource has a known concurrency budget.",
      "Concurrency, ordering, and buffering": "Each source value creates one child fiber. A semaphore admits at most\n`concurrency` inners into execution; excess fibers wait for a permit rather\nthan being dropped. Values from each inner retain local order, but admitted\ninners may interleave and output is not reordered into source order.",
      "Ownership and lifetime": "A non-positive, fractional, infinite, or unsafe-integer limit fails through\nthe Sink with `Cause.IllegalArgumentError`. Source and inner failures and\nservices remain typed. The required `Scope` owns waiting and active fibers;\nsource completion waits for all of them, and interruption cancels both groups\nand runs active inner finalizers."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Effect } from \"effect\"\n\nconst jobs = Fx.fromIterable([\n  { id: \"one\", wait: \"20 millis\" as const },\n  { id: \"two\", wait: \"20 millis\" as const },\n  { id: \"three\", wait: \"1 millis\" as const }\n])\nconst bounded = Fx.flatMapConcurrently(\n  jobs,\n  ({ id, wait }) => Fx.at(id, wait),\n  2\n)\n\nEffect.runPromise(Effect.scoped(Fx.collectAll(bounded))).then(console.log)\n// \"three\" waits for one of the first two permits despite its shorter delay"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
        "start": {
          "line": 63,
          "column": 14
        },
        "end": {
          "line": 101,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
        "start": {
          "line": 64,
          "column": 3
        },
        "end": {
          "line": 67,
          "column": 100
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/flatMapConcurrently.ts",
        "start": {
          "line": 69,
          "column": 3
        },
        "end": {
          "line": 73,
          "column": 71
        }
      }
    ],
    "since": "1.0.0",
    "category": "Concurrent work"
  }
}
