effex-monorepo
    Preparing search index...

    Interface IControlCtx<A>

    Context interface for control flow operations. Abstracts SSR/Hydration/Client differences behind a unified API.

    interface IControlCtx<A> {
        addSlot: <E, R>(
            key: string,
            render: (
                ctx: { index: Signal.Signal<number>; item: Signal.Signal<unknown> },
            ) => Element<A, E, R>,
            options?: {
                atIndex?: number;
                initialIndex?: number;
                initialItem?: unknown;
            },
        ) => Effect<SlotEntry<A>, E, R>;
        defaultContainer: Element<A, never, never>;
        finalizeContainer: () => Effect<void>;
        fork: () => Effect<IControlCtx<A>>;
        getContainer: <E, R>(create?: () => Element<A, E, R>) => Element<A, E, R>;
        getSlot: (key: string) => Effect<SlotEntry<A> | undefined>;
        getSlotKeys: () => Effect<readonly string[]>;
        moveSlot: (key: string, toIndex: number) => Effect<void>;
        removeSlot: (key: string) => Effect<void>;
        subscribe: <V, E, R>(
            readable: Readable.Readable<V>,
            handler: (value: V) => Effect<void, E, R>,
        ) => Effect<void, E, R>;
    }

    Type Parameters

    • A

      The element type (e.g., HTMLElement | SVGElement for DOM)

      Package split:

      • packages/core: Interface definition, reconcile function, thin wrappers
      • packages/dom: Live implementations (Client, Hydration, SSR)
    Index

    Properties

    addSlot: <E, R>(
        key: string,
        render: (
            ctx: { index: Signal.Signal<number>; item: Signal.Signal<unknown> },
        ) => Element<A, E, R>,
        options?: {
            atIndex?: number;
            initialIndex?: number;
            initialItem?: unknown;
        },
    ) => Effect<SlotEntry<A>, E, R>

    Add a new slot to the container. Creates item/index signals internally and passes them to render callback. Handles enter animations in client mode.

    defaultContainer: Element<A, never, never>

    Default container element. Each environment provides its own implementation. e.g., DOM uses $.div({ style: "display: contents" })

    finalizeContainer: () => Effect<void>

    Signal that the container's initial children have been processed. In hydration mode, this pops the container from the traversal stack so sibling elements are found correctly. No-op in client/SSR mode.

    fork: () => Effect<IControlCtx<A>>

    Create a child context with isolated state. Each control function (when, match, each) calls this to get its own container and slots, preventing conflicts when nested or used with collect.

    getContainer: <E, R>(create?: () => Element<A, E, R>) => Element<A, E, R>

    Get or create the container element.

    • SSR: calls create(), adds hydration markers
    • Hydration: finds existing container, falls back to create()
    • Client: calls create()

    Uses defaultContainer if create is not provided.

    getSlot: (key: string) => Effect<SlotEntry<A> | undefined>

    Get a slot by its key.

    getSlotKeys: () => Effect<readonly string[]>

    Get all current slot keys. Reads from DOM in hydration mode.

    moveSlot: (key: string, toIndex: number) => Effect<void>

    Move a slot to a new index position. Noop in SSR mode.

    removeSlot: (key: string) => Effect<void>

    Remove a slot from the container. Noop in SSR, handles exit animations in client mode.

    subscribe: <V, E, R>(
        readable: Readable.Readable<V>,
        handler: (value: V) => Effect<void, E, R>,
    ) => Effect<void, E, R>

    Subscribe to a Readable and run handler on each change. Noop in SSR, forks stream subscription in client/hydration.