{
  "id": "@typed/template#EventSource",
  "canonicalId": "@typed/template#EventSource",
  "symbol": {
    "id": "@typed/template#EventSource",
    "packageName": "@typed/template",
    "moduleName": ".",
    "exportName": "EventSource",
    "kind": "interface",
    "signatures": [
      "export interface EventSource {\n    readonly addEventListener: <Ev extends Event>(element: EventTarget, event: EventName, handler: Handler<Ev>) => Disposable;\n    readonly setup: (rendered: Rendered, scope: Scope.Scope) => Effect.Effect<void>;\n}"
    ],
    "summary": "An interface for managing event listeners on DOM nodes.\n\nIt abstracts the process of adding and removing event listeners, ensuring that they are\nproperly cleaned up when the scope is closed or the element is removed.",
    "sections": {
      "Why": "`EventSource` delegates browser events across the concrete nodes represented\nby a rendered value. A matching callback receives a non-pooled `Proxy` that\nforwards properties, binds methods to the native event, and overrides\n`currentTarget` with the registered delegated target. Handlers may be\nregistered before or after a mount.",
      "Ownership and lifetime": "`setup` binds one rendered range to an explicit Effect `Scope`. That Scope\nremoves native listeners and interrupts every handler fiber it started.\nCancellation is signaled without awaiting handlers, which may themselves\nbe publishing the update that removes this mount.\nDisposing the value returned by `addEventListener` removes only that entry.\nNo document-global registry or parallel propagation model is created, but the\ncallback event is not object-identical to the browser event because of that\n`currentTarget` Proxy.",
      "Property: addEventListener": "Registers a delegated native event handler for one concrete target.",
      "Property: addEventListener: Why": "Registration can happen before a rendered range is attached, keeping\ntemplate compilation separate from mounting.",
      "Property: addEventListener: Ownership and lifetime": "The returned Disposable removes this entry from every active mount; each\nmount Scope independently owns its native attachments.",
      "Property: setup": "Sets up event listeners for a rendered template within a scope.",
      "Property: setup: Why": "Delegation attaches to the concrete elements represented by DOM output. The\nproxy preserves the browser event's `target`, properties, and bound methods\nwhile reporting the registered element as `currentTarget`.",
      "Property: setup: Ownership and lifetime": "The supplied Scope removes listeners and interrupts handler fibers."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect, Scope } from \"effect\"\nimport { makeEventSource } from \"@typed/template/EventSource\"\nimport * as EventHandler from \"@typed/template/EventHandler\"\n\nconst program = Effect.scoped(Effect.gen(function* () {\n  const eventSource = makeEventSource()\n  const button = document.createElement(\"button\")\n\n  // Add event listener\n  const handler = EventHandler.make((event: MouseEvent) => {\n    console.log(\"Button clicked\")\n  })\n\n  const disposable = eventSource.addEventListener(button, \"click\", handler)\n\n  // Setup listeners for rendered content\n  yield* eventSource.setup(button, yield* Scope.Scope)\n\n  // Cleanup\n  disposable[Symbol.dispose]()\n}))"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/template/src/EventSource.ts",
      "line": 67
    },
    "since": "1.0.0",
    "category": "Delegated event sources"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/template#EventSource",
    "packageName": "@typed/template",
    "packageVersion": "1.0.0-beta.13",
    "moduleName": ".",
    "consumerSpecifier": "@typed/template",
    "exportName": "EventSource",
    "qualifiedName": "EventSource",
    "declarationKey": "declaration:7e2745d6d303df4a9c8d602d",
    "family": "interface",
    "signatures": [
      "export interface EventSource {\n    readonly addEventListener: <Ev extends Event>(element: EventTarget, event: EventName, handler: Handler<Ev>) => Disposable;\n    readonly setup: (rendered: Rendered, scope: Scope.Scope) => Effect.Effect<void>;\n}"
    ],
    "sourceSpans": [
      {
        "file": "packages/template/src/EventSource.ts",
        "start": {
          "line": 67,
          "column": 1
        },
        "end": {
          "line": 109,
          "column": 2
        }
      },
      {
        "file": "packages/template/src/EventSource.ts",
        "start": {
          "line": 85,
          "column": 3
        },
        "end": {
          "line": 89,
          "column": 19
        }
      },
      {
        "file": "packages/template/src/EventSource.ts",
        "start": {
          "line": 108,
          "column": 3
        },
        "end": {
          "line": 108,
          "column": 83
        }
      }
    ],
    "aliases": [
      "@typed/template/EventSource#EventSource"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:7e2745d6d303df4a9c8d602d",
    "name": "EventSource",
    "family": "interface",
    "facets": [
      {
        "family": "interface",
        "syntaxKind": "InterfaceDeclaration",
        "signatures": [
          "export interface EventSource {\n    readonly addEventListener: <Ev extends Event>(element: EventTarget, event: EventName, handler: Handler<Ev>) => Disposable;\n    readonly setup: (rendered: Rendered, scope: Scope.Scope) => Effect.Effect<void>;\n}"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/template/src/EventSource.ts",
            "start": {
              "line": 67,
              "column": 1
            },
            "end": {
              "line": 109,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertySignature",
        "signatures": [
          "readonly addEventListener: <Ev extends Event>(element: EventTarget, event: EventName, handler: Handler<Ev>) => Disposable;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/template/src/EventSource.ts",
            "start": {
              "line": 85,
              "column": 3
            },
            "end": {
              "line": 89,
              "column": 19
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertySignature",
        "signatures": [
          "readonly setup: (rendered: Rendered, scope: Scope.Scope) => Effect.Effect<void>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/template/src/EventSource.ts",
            "start": {
              "line": 108,
              "column": 3
            },
            "end": {
              "line": 108,
              "column": 83
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      }
    ],
    "signatures": [
      "export interface EventSource {\n    readonly addEventListener: <Ev extends Event>(element: EventTarget, event: EventName, handler: Handler<Ev>) => Disposable;\n    readonly setup: (rendered: Rendered, scope: Scope.Scope) => Effect.Effect<void>;\n}"
    ],
    "typeParameters": [],
    "summary": "An interface for managing event listeners on DOM nodes.\n\nIt abstracts the process of adding and removing event listeners, ensuring that they are\nproperly cleaned up when the scope is closed or the element is removed.",
    "sections": {
      "Why": "`EventSource` delegates browser events across the concrete nodes represented\nby a rendered value. A matching callback receives a non-pooled `Proxy` that\nforwards properties, binds methods to the native event, and overrides\n`currentTarget` with the registered delegated target. Handlers may be\nregistered before or after a mount.",
      "Ownership and lifetime": "`setup` binds one rendered range to an explicit Effect `Scope`. That Scope\nremoves native listeners and interrupts every handler fiber it started.\nCancellation is signaled without awaiting handlers, which may themselves\nbe publishing the update that removes this mount.\nDisposing the value returned by `addEventListener` removes only that entry.\nNo document-global registry or parallel propagation model is created, but the\ncallback event is not object-identical to the browser event because of that\n`currentTarget` Proxy.",
      "Property: addEventListener": "Registers a delegated native event handler for one concrete target.",
      "Property: addEventListener: Why": "Registration can happen before a rendered range is attached, keeping\ntemplate compilation separate from mounting.",
      "Property: addEventListener: Ownership and lifetime": "The returned Disposable removes this entry from every active mount; each\nmount Scope independently owns its native attachments.",
      "Property: setup": "Sets up event listeners for a rendered template within a scope.",
      "Property: setup: Why": "Delegation attaches to the concrete elements represented by DOM output. The\nproxy preserves the browser event's `target`, properties, and bound methods\nwhile reporting the registered element as `currentTarget`.",
      "Property: setup: Ownership and lifetime": "The supplied Scope removes listeners and interrupts handler fibers."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect, Scope } from \"effect\"\nimport { makeEventSource } from \"@typed/template/EventSource\"\nimport * as EventHandler from \"@typed/template/EventHandler\"\n\nconst program = Effect.scoped(Effect.gen(function* () {\n  const eventSource = makeEventSource()\n  const button = document.createElement(\"button\")\n\n  // Add event listener\n  const handler = EventHandler.make((event: MouseEvent) => {\n    console.log(\"Button clicked\")\n  })\n\n  const disposable = eventSource.addEventListener(button, \"click\", handler)\n\n  // Setup listeners for rendered content\n  yield* eventSource.setup(button, yield* Scope.Scope)\n\n  // Cleanup\n  disposable[Symbol.dispose]()\n}))"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/template/src/EventSource.ts",
        "start": {
          "line": 67,
          "column": 1
        },
        "end": {
          "line": 109,
          "column": 2
        }
      },
      {
        "file": "packages/template/src/EventSource.ts",
        "start": {
          "line": 85,
          "column": 3
        },
        "end": {
          "line": 89,
          "column": 19
        }
      },
      {
        "file": "packages/template/src/EventSource.ts",
        "start": {
          "line": 108,
          "column": 3
        },
        "end": {
          "line": 108,
          "column": 83
        }
      }
    ],
    "since": "1.0.0",
    "category": "Delegated event sources"
  }
}
