{
  "id": "@typed/fx#Subject.Subject",
  "canonicalId": "@typed/fx/Subject#Subject",
  "symbol": {
    "id": "@typed/fx#Subject.Subject",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "Subject.Subject",
    "kind": "interface",
    "signatures": [
      "export interface Subject<A, E = never, R = never> extends Fx.Fx<A, E, R | Scope.Scope>, Sink.Sink<A, E, R> {\n    readonly subscriberCount: Effect.Effect<number, never, R>;\n    readonly interrupt: Effect.Effect<void, never, R>;\n}",
      "export declare namespace Subject {\n    interface Service<Self, Id extends string, A, E> extends Subject<A, E, Self> {\n        readonly id: Id;\n        readonly service: Context.Service<Self, Subject<A, E>>;\n        readonly make: (replay?: number) => Layer.Layer<Self, Cause.IllegalArgumentError, Scope.Scope>;\n    }\n    interface Class<Self, Id extends string, A, E> extends Service<Self, Id, A, E> {\n        new (): Service<Self, Id, A, E>;\n    }\n}"
    ],
    "summary": "A multicast boundary that is both an `Fx` of its publications and a `Sink` that accepts them.\nSuccesses and failures are pushed to every subscriber present when that publication begins.",
    "sections": {
      "Why": "`Subject` connects imperative or independently owned producers to `Fx` without changing the\nproducer-driven direction of the work. Because the same value is also a `Sink`, another `Fx` can\npublish into it with `run` while any number of consumers subscribe through the ordinary `Fx`\nsurface.",
      "Publication order": "Publications are serialized in FIFO order, including publications made concurrently or from\ninside a subscriber callback. The subscriber set is snapshotted once per publication: a\nsubscriber removed during a delivery receives no later publication, and a subscriber added\nduring a delivery begins with the next publication. A failure publication uses the error channel\nbut does not permanently terminate the subject. A reentrant `onSuccess` or `onFailure` call from\nthe fiber currently draining subscribers enqueues its publication and returns before that queued\npublication is delivered; the outer drain still delivers it in FIFO order.",
      "Ownership and lifetime": "Each call to `run` registers its sink in the caller's `Scope`; closing that scope removes only\nthat subscription. `interrupt` closes all current subscriber scopes and clears retained replay\nstate. A subject created by `make` is interrupted automatically when its owning scope closes;\n`unsafeMake` leaves that responsibility with the caller.",
      "Property: interrupt": "Interrupts every current subscription and clears any retained replay values.",
      "Property: interrupt: Why": "Gives the subject owner one deterministic shutdown operation for all active consumers and\nretained publications.",
      "Property: interrupt: Ownership and lifetime": "Closing subscriber scopes runs their finalizers. The effect cannot fail, and the subject may be\nsubscribed to and published through again after the interruption.",
      "Property: subscriberCount": "Samples the number of sinks currently registered with this subject.",
      "Property: subscriberCount: Why": "Exposes demand for diagnostics and demand-sensitive coordination without coupling producers to\nthe subject implementation.",
      "Property: subscriberCount: Ownership and lifetime": "The returned `Effect` does not subscribe or retain anything. It reads the count when executed\nand requires the same services `R` as the subject implementation."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect, Fiber } from \"effect\"\nimport { Fx } from \"@typed/fx\"\nimport * as Subject from \"@typed/fx/Subject\"\n\nconst program = Effect.gen(function* () {\n  const events = yield* Subject.make<string>(2)\n  const collected = yield* Effect.forkScoped(Fx.collectAll(Fx.take(events, 2)))\n\n  yield* events.onSuccess(\"connected\")\n  yield* events.onSuccess(\"ready\")\n\n  return yield* Fiber.join(collected)\n}).pipe(Effect.scoped)"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Subject/Subject.ts",
      "line": 69
    },
    "since": "1.0.0",
    "category": "Publication contracts"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#Subject.Subject",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "Subject",
    "qualifiedName": "Subject.Subject",
    "declarationKey": "declaration:d4f4ee738c96fa2ee8992f77",
    "family": "interface",
    "signatures": [
      "export interface Subject<A, E = never, R = never> extends Fx.Fx<A, E, R | Scope.Scope>, Sink.Sink<A, E, R> {\n    readonly subscriberCount: Effect.Effect<number, never, R>;\n    readonly interrupt: Effect.Effect<void, never, R>;\n}",
      "export declare namespace Subject {\n    interface Service<Self, Id extends string, A, E> extends Subject<A, E, Self> {\n        readonly id: Id;\n        readonly service: Context.Service<Self, Subject<A, E>>;\n        readonly make: (replay?: number) => Layer.Layer<Self, Cause.IllegalArgumentError, Scope.Scope>;\n    }\n    interface Class<Self, Id extends string, A, E> extends Service<Self, Id, A, E> {\n        new (): Service<Self, Id, A, E>;\n    }\n}"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 69,
          "column": 1
        },
        "end": {
          "line": 107,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 109,
          "column": 1
        },
        "end": {
          "line": 239,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 106,
          "column": 3
        },
        "end": {
          "line": 106,
          "column": 53
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 88,
          "column": 3
        },
        "end": {
          "line": 88,
          "column": 61
        }
      }
    ],
    "aliases": [
      "@typed/fx/Subject#Subject"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#Subject",
    "static": false,
    "importedFrom": "declaration:d4f4ee738c96fa2ee8992f77"
  },
  "declaration": {
    "declarationKey": "declaration:d4f4ee738c96fa2ee8992f77",
    "name": "Subject",
    "family": "interface",
    "facets": [
      {
        "family": "interface",
        "syntaxKind": "InterfaceDeclaration",
        "signatures": [
          "export interface Subject<A, E = never, R = never> extends Fx.Fx<A, E, R | Scope.Scope>, Sink.Sink<A, E, R> {\n    readonly subscriberCount: Effect.Effect<number, never, R>;\n    readonly interrupt: Effect.Effect<void, never, R>;\n}"
        ],
        "typeParameters": [
          "A",
          "E = never",
          "R = never"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 69,
              "column": 1
            },
            "end": {
              "line": 107,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "namespace",
        "syntaxKind": "ModuleDeclaration",
        "signatures": [
          "export declare namespace Subject {\n    interface Service<Self, Id extends string, A, E> extends Subject<A, E, Self> {\n        readonly id: Id;\n        readonly service: Context.Service<Self, Subject<A, E>>;\n        readonly make: (replay?: number) => Layer.Layer<Self, Cause.IllegalArgumentError, Scope.Scope>;\n    }\n    interface Class<Self, Id extends string, A, E> extends Service<Self, Id, A, E> {\n        new (): Service<Self, Id, A, E>;\n    }\n}"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 109,
              "column": 1
            },
            "end": {
              "line": 239,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertySignature",
        "signatures": [
          "readonly interrupt: Effect.Effect<void, never, R>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 106,
              "column": 3
            },
            "end": {
              "line": 106,
              "column": 53
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertySignature",
        "signatures": [
          "readonly subscriberCount: Effect.Effect<number, never, R>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Subject/Subject.ts",
            "start": {
              "line": 88,
              "column": 3
            },
            "end": {
              "line": 88,
              "column": 61
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      }
    ],
    "signatures": [
      "export interface Subject<A, E = never, R = never> extends Fx.Fx<A, E, R | Scope.Scope>, Sink.Sink<A, E, R> {\n    readonly subscriberCount: Effect.Effect<number, never, R>;\n    readonly interrupt: Effect.Effect<void, never, R>;\n}",
      "export declare namespace Subject {\n    interface Service<Self, Id extends string, A, E> extends Subject<A, E, Self> {\n        readonly id: Id;\n        readonly service: Context.Service<Self, Subject<A, E>>;\n        readonly make: (replay?: number) => Layer.Layer<Self, Cause.IllegalArgumentError, Scope.Scope>;\n    }\n    interface Class<Self, Id extends string, A, E> extends Service<Self, Id, A, E> {\n        new (): Service<Self, Id, A, E>;\n    }\n}"
    ],
    "typeParameters": [
      "A",
      "E = never",
      "R = never"
    ],
    "summary": "A multicast boundary that is both an `Fx` of its publications and a `Sink` that accepts them.\nSuccesses and failures are pushed to every subscriber present when that publication begins.",
    "sections": {
      "Why": "`Subject` connects imperative or independently owned producers to `Fx` without changing the\nproducer-driven direction of the work. Because the same value is also a `Sink`, another `Fx` can\npublish into it with `run` while any number of consumers subscribe through the ordinary `Fx`\nsurface.",
      "Publication order": "Publications are serialized in FIFO order, including publications made concurrently or from\ninside a subscriber callback. The subscriber set is snapshotted once per publication: a\nsubscriber removed during a delivery receives no later publication, and a subscriber added\nduring a delivery begins with the next publication. A failure publication uses the error channel\nbut does not permanently terminate the subject. A reentrant `onSuccess` or `onFailure` call from\nthe fiber currently draining subscribers enqueues its publication and returns before that queued\npublication is delivered; the outer drain still delivers it in FIFO order.",
      "Ownership and lifetime": "Each call to `run` registers its sink in the caller's `Scope`; closing that scope removes only\nthat subscription. `interrupt` closes all current subscriber scopes and clears retained replay\nstate. A subject created by `make` is interrupted automatically when its owning scope closes;\n`unsafeMake` leaves that responsibility with the caller.",
      "Property: interrupt": "Interrupts every current subscription and clears any retained replay values.",
      "Property: interrupt: Why": "Gives the subject owner one deterministic shutdown operation for all active consumers and\nretained publications.",
      "Property: interrupt: Ownership and lifetime": "Closing subscriber scopes runs their finalizers. The effect cannot fail, and the subject may be\nsubscribed to and published through again after the interruption.",
      "Property: subscriberCount": "Samples the number of sinks currently registered with this subject.",
      "Property: subscriberCount: Why": "Exposes demand for diagnostics and demand-sensitive coordination without coupling producers to\nthe subject implementation.",
      "Property: subscriberCount: Ownership and lifetime": "The returned `Effect` does not subscribe or retain anything. It reads the count when executed\nand requires the same services `R` as the subject implementation."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect, Fiber } from \"effect\"\nimport { Fx } from \"@typed/fx\"\nimport * as Subject from \"@typed/fx/Subject\"\n\nconst program = Effect.gen(function* () {\n  const events = yield* Subject.make<string>(2)\n  const collected = yield* Effect.forkScoped(Fx.collectAll(Fx.take(events, 2)))\n\n  yield* events.onSuccess(\"connected\")\n  yield* events.onSuccess(\"ready\")\n\n  return yield* Fiber.join(collected)\n}).pipe(Effect.scoped)"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 69,
          "column": 1
        },
        "end": {
          "line": 107,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 109,
          "column": 1
        },
        "end": {
          "line": 239,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 106,
          "column": 3
        },
        "end": {
          "line": 106,
          "column": 53
        }
      },
      {
        "file": "packages/fx/src/Subject/Subject.ts",
        "start": {
          "line": 88,
          "column": 3
        },
        "end": {
          "line": 88,
          "column": 61
        }
      }
    ],
    "since": "1.0.0",
    "category": "Publication contracts"
  }
}
