/** * Cell -- writable reactive primitive. * * @module */ import type { Scope } from 'effect'; import { Effect, Stream, SubscriptionRef } from 'effect'; interface CellShape { readonly _tag: 'Cell'; readonly ref: SubscriptionRef.SubscriptionRef; readonly changes: Stream.Stream; readonly get: Effect.Effect; set(value: T): Effect.Effect; update(f: (current: T) => T): Effect.Effect; } /** * Read all values from a tuple of cells, preserving the tuple type `T`. * * Sanctioned single cast site for Cell combinators. Two type-system gaps force * this containment: * 1. `tupleMap`'s callback signature collapses to `U = Effect`, * losing the per-element `Effect` relationship. * 2. `Effect.all`'s tuple overload returns a mapped-tuple result * `{ -readonly [K in keyof ...]: _A }` that TypeScript cannot fold back * to the input tuple type `T` (`T` could be instantiated with an * arbitrary subtype per the structural contravariance rules). * * The runtime behavior is provably correct: `tupleMap` is total and order- * preserving, `Effect.all` with an array input preserves positional order and * arity, so the resulting values are `T` by construction. */ export declare const readAllCellValues: (cells: { readonly [K in keyof T]: CellShape; }) => Effect.Effect; /** * Cell — mutable reactive primitive backed by `SubscriptionRef`. * The workhorse of czap's reactive graph: `get` for a snapshot, `set` to * push, `changes` for the stream of subsequent values. */ export declare const Cell: { /** Build a cell with an initial value. */ make: (initial: T) => Effect.Effect>; /** Seed a cell with an initial value and mirror every stream emission into it. */ fromStream: (initial: T, source: Stream.Stream) => Effect.Effect, never, Scope.Scope>; /** Tuple-combine cells into a single cell of their current values. */ all: (cells: { readonly [K in keyof T]: CellShape; }) => Effect.Effect, never, Scope.Scope>; /** Scoped `map` — derive a new cell by applying `fn` to every emission. */ map: (cell: CellShape, fn: (value: T) => U) => Effect.Effect, never, Scope.Scope>; }; export declare namespace Cell { /** Structural shape of a {@link Cell}: `_tag`, `get`, `set`, `changes`. */ type Shape = CellShape; } export {}; //# sourceMappingURL=cell.d.ts.map