{
  "id": "@typed/fx/Subject#share",
  "canonicalId": "@typed/fx/Subject#share",
  "symbol": {
    "id": "@typed/fx/Subject#share",
    "packageName": "@typed/fx",
    "moduleName": "Subject",
    "exportName": "share",
    "kind": "function",
    "signatures": [
      "export declare function share<A, E, R, R2>(fx: Fx.Fx<A, E, R>, subject: Subject<A, E, R2>): Fx.Fx<A, E, R | R2 | Scope.Scope>;"
    ],
    "summary": "Shares one active execution of an `Fx` among subscribers through the supplied `Subject`.",
    "sections": {
      "Why": "Use `share` when the caller must choose the multicast boundary—for example, a replaying subject,\na renderer-independent state object, or a service-backed subject—while ensuring that simultaneous\nconsumers do not duplicate the source's effects.",
      "Subscription and publication": "A subscriber is registered with the subject before the source starts, so the first subscriber\nobserves synchronous first values and failures. The first active subscriber starts the source;\nlater subscribers join that execution. When the last subscriber leaves, the source fiber is\ninterrupted. A later subscriber starts a fresh session.",
      "Errors, services, and interruption": "Source successes and failures are pushed unchanged through the subject. The returned `Fx`\nrequires the union of source services and subject services.",
      "Ownership and lifetime": "`Scope` owns each individual subscription. The shared source is finalized exactly once when the\nactive session ends or the source itself exits. `share` takes session ownership of the supplied\nsubject: source exit calls its `interrupt`, closing all of that subject's subscribers and clearing\nretained state. Do not concurrently reuse the same subject for an independently owned producer\nor subscriber population."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { Fx } from \"@typed/fx\"\nimport * as Subject from \"@typed/fx/Subject\"\n\nconst backing = Subject.unsafeMake<number>(1)\nconst request = Fx.fromEffect(Effect.succeed(42))\nconst shared = Subject.share(request, backing)"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Subject/Subject.ts",
      "line": 288
    },
    "since": "1.0.0",
    "category": "Sharing sources"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Subject#share",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": "Subject",
    "consumerSpecifier": "@typed/fx/Subject",
    "exportName": "share",
    "qualifiedName": "share",
    "declarationKey": "declaration:234fb33554c6394fe48fc5d9",
    "family": "function",
    "signatures": [
      "export declare function share<A, E, R, R2>(fx: Fx.Fx<A, E, R>, subject: Subject<A, E, R2>): Fx.Fx<A, E, R | R2 | Scope.Scope>;"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 288,
          "column": 1
        },
        "end": {
          "line": 293,
          "column": 2
        }
      }
    ],
    "aliases": [
      "@typed/fx#Subject.share"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:234fb33554c6394fe48fc5d9",
    "name": "share",
    "family": "function",
    "facets": [
      {
        "family": "function",
        "syntaxKind": "FunctionDeclaration",
        "signatures": [
          "export declare function share<A, E, R, R2>(fx: Fx.Fx<A, E, R>, subject: Subject<A, E, R2>): Fx.Fx<A, E, R | R2 | Scope.Scope>;"
        ],
        "typeParameters": [
          "A",
          "E",
          "R",
          "R2"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 288,
              "column": 1
            },
            "end": {
              "line": 293,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare function share<A, E, R, R2>(fx: Fx.Fx<A, E, R>, subject: Subject<A, E, R2>): Fx.Fx<A, E, R | R2 | Scope.Scope>;"
    ],
    "typeParameters": [
      "A",
      "E",
      "R",
      "R2"
    ],
    "summary": "Shares one active execution of an `Fx` among subscribers through the supplied `Subject`.",
    "sections": {
      "Why": "Use `share` when the caller must choose the multicast boundary—for example, a replaying subject,\na renderer-independent state object, or a service-backed subject—while ensuring that simultaneous\nconsumers do not duplicate the source's effects.",
      "Subscription and publication": "A subscriber is registered with the subject before the source starts, so the first subscriber\nobserves synchronous first values and failures. The first active subscriber starts the source;\nlater subscribers join that execution. When the last subscriber leaves, the source fiber is\ninterrupted. A later subscriber starts a fresh session.",
      "Errors, services, and interruption": "Source successes and failures are pushed unchanged through the subject. The returned `Fx`\nrequires the union of source services and subject services.",
      "Ownership and lifetime": "`Scope` owns each individual subscription. The shared source is finalized exactly once when the\nactive session ends or the source itself exits. `share` takes session ownership of the supplied\nsubject: source exit calls its `interrupt`, closing all of that subject's subscribers and clearing\nretained state. Do not concurrently reuse the same subject for an independently owned producer\nor subscriber population."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { Fx } from \"@typed/fx\"\nimport * as Subject from \"@typed/fx/Subject\"\n\nconst backing = Subject.unsafeMake<number>(1)\nconst request = Fx.fromEffect(Effect.succeed(42))\nconst shared = Subject.share(request, backing)"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 288,
          "column": 1
        },
        "end": {
          "line": 293,
          "column": 2
        }
      }
    ],
    "since": "1.0.0",
    "category": "Sharing sources"
  }
}
