{
  "id": "@typed/fx/Fx#callback",
  "canonicalId": "@typed/fx/Fx#callback",
  "symbol": {
    "id": "@typed/fx/Fx#callback",
    "packageName": "@typed/fx",
    "moduleName": "Fx",
    "exportName": "callback",
    "kind": "constant",
    "signatures": [
      "export declare const callback: <A, E = never, R = never>(run: (emit: Emit<A, E>) => void | Effect.Effect<unknown, never, R>) => Fx<A, E, R>;"
    ],
    "summary": "Creates an Fx from a callback-based source.",
    "sections": {
      "Why": "DOM events, sockets, observers, and foreign libraries decide when values exist.\n`callback` turns that push boundary into `Fx` while keeping failure and cleanup\ninside Effect's structured lifetime.",
      "Ownership and lifetime": "Registration is lazy: `run` is called once for each `Fx` run. The run creates a\nchild scope and stays active until `emit.done()`, sink early exit, or interruption.\nIf `run` returns an Effect, it is registered as the scope finalizer. Each emit\noperation starts its sink handler in a fiber, so handler completion can overlap;\nuse the returned fibers or a serialized source when ordering of effects matters."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { callback, collectUpTo } from \"@typed/fx/Fx\"\n\nconst messages = callback<string>((emit) => {\n  const timer = setInterval(() => emit.succeed(\"tick\"), 10)\n  return Effect.sync(() => clearInterval(timer))\n})\nconst program = collectUpTo(messages, 2)"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/constructors/make.ts",
      "line": 215
    },
    "since": "1.0.0",
    "category": "Callback sources"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Fx#callback",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.13",
    "moduleName": "Fx",
    "consumerSpecifier": "@typed/fx/Fx",
    "exportName": "callback",
    "qualifiedName": "callback",
    "declarationKey": "declaration:6d2a824f6944b4613b153136",
    "family": "variable",
    "signatures": [
      "export declare const callback: <A, E = never, R = never>(run: (emit: Emit<A, E>) => void | Effect.Effect<unknown, never, R>) => Fx<A, E, R>;"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/constructors/make.ts",
        "start": {
          "line": 215,
          "column": 14
        },
        "end": {
          "line": 246,
          "column": 4
        }
      }
    ],
    "aliases": [
      "@typed/fx#Fx.callback"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:6d2a824f6944b4613b153136",
    "name": "callback",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const callback: <A, E = never, R = never>(run: (emit: Emit<A, E>) => void | Effect.Effect<unknown, never, R>) => Fx<A, E, R>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/constructors/make.ts",
            "start": {
              "line": 215,
              "column": 14
            },
            "end": {
              "line": 246,
              "column": 4
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const callback: <A, E = never, R = never>(run: (emit: Emit<A, E>) => void | Effect.Effect<unknown, never, R>) => Fx<A, E, R>;"
    ],
    "typeParameters": [],
    "summary": "Creates an Fx from a callback-based source.",
    "sections": {
      "Why": "DOM events, sockets, observers, and foreign libraries decide when values exist.\n`callback` turns that push boundary into `Fx` while keeping failure and cleanup\ninside Effect's structured lifetime.",
      "Ownership and lifetime": "Registration is lazy: `run` is called once for each `Fx` run. The run creates a\nchild scope and stays active until `emit.done()`, sink early exit, or interruption.\nIf `run` returns an Effect, it is registered as the scope finalizer. Each emit\noperation starts its sink handler in a fiber, so handler completion can overlap;\nuse the returned fibers or a serialized source when ordering of effects matters."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport { callback, collectUpTo } from \"@typed/fx/Fx\"\n\nconst messages = callback<string>((emit) => {\n  const timer = setInterval(() => emit.succeed(\"tick\"), 10)\n  return Effect.sync(() => clearInterval(timer))\n})\nconst program = collectUpTo(messages, 2)"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/constructors/make.ts",
        "start": {
          "line": 215,
          "column": 14
        },
        "end": {
          "line": 246,
          "column": 4
        }
      }
    ],
    "since": "1.0.0",
    "category": "Callback sources"
  }
}
