{
  "id": "@typed/fx#Subject.Share",
  "canonicalId": "@typed/fx/Subject#Share",
  "symbol": {
    "id": "@typed/fx#Subject.Share",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "Subject.Share",
    "kind": "class",
    "signatures": [
      "export declare class Share<A, E, R, R2> implements Fx.Fx<A, E, R | R2 | Scope.Scope> {\n    readonly [FxTypeId]: Fx.Fx.Variance<A, E, R | R2 | Scope.Scope>;\n    _FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<unknown>>>;\n    _RefCount: RefCounter;\n    readonly i0: Fx.Fx<A, E, R>;\n    readonly i1: Subject<A, E, R2>;\n    constructor(i0: Fx.Fx<A, E, R>, i1: Subject<A, E, R2>);\n    pipe(): unknown;\n    run<R3>(sink: Sink.Sink<A, E, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope>;\n}"
    ],
    "summary": "The concrete lazy `Fx` returned by `share`.",
    "sections": {
      "Why": "`Share` exposes the ref-counted sharing mechanism as an ordinary `Fx`: one source execution feeds\nthe selected subject while each caller has an independently scoped subscription to that subject.\nMost callers should prefer `share`, `multicast`, `hold`, or `replay` for clearer intent.",
      "Ownership and lifetime": "Construction acquires nothing. The first executing `run` starts a detached source fiber; the\nfinal executing `run` interrupts it. Source completion interrupts the subject's current\nsubscribers. Source, subject, and sink services are required only when `run` executes.",
      "Constructor": "Creates the lazy shared `Fx`; source acquisition waits until the first call to `run` executes.",
      "Constructor: Why": "Keeps selection of the source and multicast policy separate from their execution.",
      "Constructor: Ownership and lifetime": "The constructor only stores `i0` and `i1`; it starts no fiber and installs no finalizer.",
      "Property: [[computed:[FxTypeId]]]": "Carries `Fx` variance information for the shared output, error, and service channels.",
      "Property: [[computed:[FxTypeId]]]: Why": "Lets generic `Fx` utilities recognize and infer a `Share` without inspecting its runtime fields.",
      "Property: [[computed:[FxTypeId]]]: Ownership and lifetime": "The marker is immutable metadata and acquires no resources.",
      "Property: _FxFiber": "Tracks the source fiber for the current active subscriber session.",
      "Property: _FxFiber: Why": "Gives the final departing subscriber an exact fiber to interrupt without restarting or\nduplicating the source.",
      "Property: _FxFiber: Ownership and lifetime": "The reference is empty before a session, set after the first subscriber starts the source, and\ncleared before or when that session ends. It does not outlive the `Share` instance.",
      "Property: _RefCount": "Tracks how many executing `run` effects participate in the active source session.",
      "Property: _RefCount: Why": "Implements the first-subscriber start and last-subscriber stop boundary.",
      "Property: _RefCount: Ownership and lifetime": "The counter is owned by the `Share` instance and never falls below zero. Each executing `run`\nincrements once and decrements in its exit finalizer.",
      "Property: i0": "The source whose execution is shared.",
      "Property: i0: Why": "Retains the original source so every active session can start exactly that `Fx`.",
      "Property: i0: Ownership and lifetime": "Holding the `Fx` value starts no work. Its `R` services and cleanup participate only while a\nsubscriber session is active.",
      "Property: i1": "The multicast subject receiving source publications.",
      "Property: i1: Why": "Separates source sharing from retention and publication policy.",
      "Property: i1: Ownership and lifetime": "`Share` does not allocate this subject. It subscribes sinks to it and interrupts it when the\nsource session exits; the subject's `R2` services remain required by `run`.",
      "Method: pipe": "Returns this value through the concrete class's zero-argument pipe entrypoint.",
      "Method: pipe: Why": "Supplies the runtime pipe hook required by `Fx`; the concrete `Share` declaration currently\npublishes only its zero-argument signature, so typed combinator composition should target the\n`Fx` returned by `share`, `multicast`, `hold`, or `replay`.",
      "Method: pipe: Ownership and lifetime": "Calling `pipe` itself acquires no resources; only an executing downstream `run` starts work.",
      "Method: run": "Registers `sink`, joins or starts the active source session, and remains active until the\nsubscription ends. Interruption removes this subscriber and stops the source if it was last.",
      "Method: run: Why": "Implements `Fx` consumption while coordinating one source execution across independent sinks.",
      "Method: run: Ownership and lifetime": "The caller's `Scope` owns its subject subscription. Source `R`, subject `R2`, and sink `R3`\nservices are required during execution. Source failures are published to the sink rather than\nfailing this returned Effect, whose error channel is `never`."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Share, unsafeMake } from \"@typed/fx/Subject\"\n\nconst shared = new Share(Fx.succeed(1), unsafeMake<number>())"
      },
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Share, unsafeMake } from \"@typed/fx/Subject\"\n\nconst shared = new Share(Fx.succeed(\"ready\"), unsafeMake<string>())"
      },
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Share, unsafeMake } from \"@typed/fx/Subject\"\n\nconst shared = new Share(Fx.succeed(1), unsafeMake<number>())\nconst same = shared.pipe()"
      },
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { Fx } from \"@typed/fx\"\nimport * as Sink from \"@typed/fx/Sink\"\nimport { Share, unsafeMake } from \"@typed/fx/Subject\"\n\nconst shared = new Share(Fx.succeed(1), unsafeMake<number>())\nconst run = shared.run(\n  Sink.make(\n    () => Effect.void,\n    (value) => Effect.sync(() => console.log(value))\n  )\n)"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Subject/Subject.ts",
      "line": 350
    },
    "since": "1.0.0",
    "category": "Sharing sources"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#Subject.Share",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.13",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "Subject",
    "qualifiedName": "Subject.Share",
    "declarationKey": "declaration:34a8efd16f7829779f91511c",
    "family": "class",
    "signatures": [
      "export declare class Share<A, E, R, R2> implements Fx.Fx<A, E, R | R2 | Scope.Scope> {\n    readonly [FxTypeId]: Fx.Fx.Variance<A, E, R | R2 | Scope.Scope>;\n    _FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<unknown>>>;\n    _RefCount: RefCounter;\n    readonly i0: Fx.Fx<A, E, R>;\n    readonly i1: Subject<A, E, R2>;\n    constructor(i0: Fx.Fx<A, E, R>, i1: Subject<A, E, R2>);\n    pipe(): unknown;\n    run<R3>(sink: Sink.Sink<A, E, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope>;\n}"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 350,
          "column": 1
        },
        "end": {
          "line": 572,
          "column": 2
        }
      },
      {
        "file": "packages/fx/dist/Subject/Subject.d.ts",
        "start": {
          "line": 420,
          "column": 5
        },
        "end": {
          "line": 420,
          "column": 60
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 366,
          "column": 3
        },
        "end": {
          "line": 366,
          "column": 78
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 385,
          "column": 3
        },
        "end": {
          "line": 387,
          "column": 5
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 404,
          "column": 3
        },
        "end": {
          "line": 404,
          "column": 32
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 422,
          "column": 3
        },
        "end": {
          "line": 422,
          "column": 31
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 439,
          "column": 3
        },
        "end": {
          "line": 439,
          "column": 34
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 495,
          "column": 3
        },
        "end": {
          "line": 497,
          "column": 4
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 533,
          "column": 3
        },
        "end": {
          "line": 542,
          "column": 4
        }
      }
    ],
    "aliases": [
      "@typed/fx/Subject#Share"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#Subject",
    "static": false,
    "importedFrom": "declaration:34a8efd16f7829779f91511c"
  },
  "declaration": {
    "declarationKey": "declaration:34a8efd16f7829779f91511c",
    "name": "Share",
    "family": "class",
    "facets": [
      {
        "family": "class",
        "syntaxKind": "ClassDeclaration",
        "signatures": [
          "export declare class Share<A, E, R, R2> implements Fx.Fx<A, E, R | R2 | Scope.Scope> {\n    readonly [FxTypeId]: Fx.Fx.Variance<A, E, R | R2 | Scope.Scope>;\n    _FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<unknown>>>;\n    _RefCount: RefCounter;\n    readonly i0: Fx.Fx<A, E, R>;\n    readonly i1: Subject<A, E, R2>;\n    constructor(i0: Fx.Fx<A, E, R>, i1: Subject<A, E, R2>);\n    pipe(): unknown;\n    run<R3>(sink: Sink.Sink<A, E, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope>;\n}"
        ],
        "typeParameters": [
          "A",
          "E",
          "R",
          "R2"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 350,
              "column": 1
            },
            "end": {
              "line": 572,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "constructor",
        "syntaxKind": "Constructor",
        "signatures": [
          "constructor(i0: Fx.Fx<A, E, R>, i1: Subject<A, E, R2>);"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/dist/Subject/Subject.d.ts",
            "start": {
              "line": 420,
              "column": 5
            },
            "end": {
              "line": 420,
              "column": 60
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertyDeclaration",
        "signatures": [
          "readonly [FxTypeId]: Fx.Fx.Variance<A, E, R | R2 | Scope.Scope>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 366,
              "column": 3
            },
            "end": {
              "line": 366,
              "column": 78
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertyDeclaration",
        "signatures": [
          "_FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<unknown>>>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 385,
              "column": 3
            },
            "end": {
              "line": 387,
              "column": 5
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertyDeclaration",
        "signatures": [
          "_RefCount: RefCounter;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 404,
              "column": 3
            },
            "end": {
              "line": 404,
              "column": 32
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertyDeclaration",
        "signatures": [
          "readonly i0: Fx.Fx<A, E, R>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 422,
              "column": 3
            },
            "end": {
              "line": 422,
              "column": 31
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertyDeclaration",
        "signatures": [
          "readonly i1: Subject<A, E, R2>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 439,
              "column": 3
            },
            "end": {
              "line": 439,
              "column": 34
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      },
      {
        "family": "method",
        "syntaxKind": "MethodDeclaration",
        "signatures": [
          "pipe(): unknown;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 495,
              "column": 3
            },
            "end": {
              "line": 497,
              "column": 4
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "method",
        "syntaxKind": "MethodDeclaration",
        "signatures": [
          "run<R3>(sink: Sink.Sink<A, E, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope>;"
        ],
        "typeParameters": [
          "R3"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 533,
              "column": 3
            },
            "end": {
              "line": 542,
              "column": 4
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare class Share<A, E, R, R2> implements Fx.Fx<A, E, R | R2 | Scope.Scope> {\n    readonly [FxTypeId]: Fx.Fx.Variance<A, E, R | R2 | Scope.Scope>;\n    _FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<unknown>>>;\n    _RefCount: RefCounter;\n    readonly i0: Fx.Fx<A, E, R>;\n    readonly i1: Subject<A, E, R2>;\n    constructor(i0: Fx.Fx<A, E, R>, i1: Subject<A, E, R2>);\n    pipe(): unknown;\n    run<R3>(sink: Sink.Sink<A, E, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope>;\n}"
    ],
    "typeParameters": [
      "A",
      "E",
      "R",
      "R2",
      "R3"
    ],
    "summary": "The concrete lazy `Fx` returned by `share`.",
    "sections": {
      "Why": "`Share` exposes the ref-counted sharing mechanism as an ordinary `Fx`: one source execution feeds\nthe selected subject while each caller has an independently scoped subscription to that subject.\nMost callers should prefer `share`, `multicast`, `hold`, or `replay` for clearer intent.",
      "Ownership and lifetime": "Construction acquires nothing. The first executing `run` starts a detached source fiber; the\nfinal executing `run` interrupts it. Source completion interrupts the subject's current\nsubscribers. Source, subject, and sink services are required only when `run` executes.",
      "Constructor": "Creates the lazy shared `Fx`; source acquisition waits until the first call to `run` executes.",
      "Constructor: Why": "Keeps selection of the source and multicast policy separate from their execution.",
      "Constructor: Ownership and lifetime": "The constructor only stores `i0` and `i1`; it starts no fiber and installs no finalizer.",
      "Property: [[computed:[FxTypeId]]]": "Carries `Fx` variance information for the shared output, error, and service channels.",
      "Property: [[computed:[FxTypeId]]]: Why": "Lets generic `Fx` utilities recognize and infer a `Share` without inspecting its runtime fields.",
      "Property: [[computed:[FxTypeId]]]: Ownership and lifetime": "The marker is immutable metadata and acquires no resources.",
      "Property: _FxFiber": "Tracks the source fiber for the current active subscriber session.",
      "Property: _FxFiber: Why": "Gives the final departing subscriber an exact fiber to interrupt without restarting or\nduplicating the source.",
      "Property: _FxFiber: Ownership and lifetime": "The reference is empty before a session, set after the first subscriber starts the source, and\ncleared before or when that session ends. It does not outlive the `Share` instance.",
      "Property: _RefCount": "Tracks how many executing `run` effects participate in the active source session.",
      "Property: _RefCount: Why": "Implements the first-subscriber start and last-subscriber stop boundary.",
      "Property: _RefCount: Ownership and lifetime": "The counter is owned by the `Share` instance and never falls below zero. Each executing `run`\nincrements once and decrements in its exit finalizer.",
      "Property: i0": "The source whose execution is shared.",
      "Property: i0: Why": "Retains the original source so every active session can start exactly that `Fx`.",
      "Property: i0: Ownership and lifetime": "Holding the `Fx` value starts no work. Its `R` services and cleanup participate only while a\nsubscriber session is active.",
      "Property: i1": "The multicast subject receiving source publications.",
      "Property: i1: Why": "Separates source sharing from retention and publication policy.",
      "Property: i1: Ownership and lifetime": "`Share` does not allocate this subject. It subscribes sinks to it and interrupts it when the\nsource session exits; the subject's `R2` services remain required by `run`.",
      "Method: pipe": "Returns this value through the concrete class's zero-argument pipe entrypoint.",
      "Method: pipe: Why": "Supplies the runtime pipe hook required by `Fx`; the concrete `Share` declaration currently\npublishes only its zero-argument signature, so typed combinator composition should target the\n`Fx` returned by `share`, `multicast`, `hold`, or `replay`.",
      "Method: pipe: Ownership and lifetime": "Calling `pipe` itself acquires no resources; only an executing downstream `run` starts work.",
      "Method: run": "Registers `sink`, joins or starts the active source session, and remains active until the\nsubscription ends. Interruption removes this subscriber and stops the source if it was last.",
      "Method: run: Why": "Implements `Fx` consumption while coordinating one source execution across independent sinks.",
      "Method: run: Ownership and lifetime": "The caller's `Scope` owns its subject subscription. Source `R`, subject `R2`, and sink `R3`\nservices are required during execution. Source failures are published to the sink rather than\nfailing this returned Effect, whose error channel is `never`."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Share, unsafeMake } from \"@typed/fx/Subject\"\n\nconst shared = new Share(Fx.succeed(1), unsafeMake<number>())"
      },
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Share, unsafeMake } from \"@typed/fx/Subject\"\n\nconst shared = new Share(Fx.succeed(\"ready\"), unsafeMake<string>())"
      },
      {
        "language": "ts",
        "code": "import { Fx } from \"@typed/fx\"\nimport { Share, unsafeMake } from \"@typed/fx/Subject\"\n\nconst shared = new Share(Fx.succeed(1), unsafeMake<number>())\nconst same = shared.pipe()"
      },
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { Fx } from \"@typed/fx\"\nimport * as Sink from \"@typed/fx/Sink\"\nimport { Share, unsafeMake } from \"@typed/fx/Subject\"\n\nconst shared = new Share(Fx.succeed(1), unsafeMake<number>())\nconst run = shared.run(\n  Sink.make(\n    () => Effect.void,\n    (value) => Effect.sync(() => console.log(value))\n  )\n)"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 350,
          "column": 1
        },
        "end": {
          "line": 572,
          "column": 2
        }
      },
      {
        "file": "packages/fx/dist/Subject/Subject.d.ts",
        "start": {
          "line": 420,
          "column": 5
        },
        "end": {
          "line": 420,
          "column": 60
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 366,
          "column": 3
        },
        "end": {
          "line": 366,
          "column": 78
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 385,
          "column": 3
        },
        "end": {
          "line": 387,
          "column": 5
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 404,
          "column": 3
        },
        "end": {
          "line": 404,
          "column": 32
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 422,
          "column": 3
        },
        "end": {
          "line": 422,
          "column": 31
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 439,
          "column": 3
        },
        "end": {
          "line": 439,
          "column": 34
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 495,
          "column": 3
        },
        "end": {
          "line": 497,
          "column": 4
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 533,
          "column": 3
        },
        "end": {
          "line": 542,
          "column": 4
        }
      }
    ],
    "since": "1.0.0",
    "category": "Sharing sources"
  }
}
