gradum-kit - v0.1.0
    Preparing search index...

    Type Alias SignalBox<Type>

    SignalBox: Type & SignalEntry<Type> & {
        toJSON(): Type;
        valueOf(): Type;
        value: Type;
        "[toPrimitive]"(hint: "string" | "number" | "default"): string | number;
    }

    Type Parameters

    • Type

      The type of the value held by the signal.

    A SignalEntry that can also be used directly as its underlying value. It coerces to the inner value in string, number, and JSON contexts, so it can usually be dropped in wherever the raw value was expected.

    const count: SignalBox<number> = signal(0);

    // Read
    console.log(count.get()); // 0
    console.log(count.value); // 0
    console.log(+count); // 0

    // Write
    count.set(5);
    count.value = 6;
    count.update(v => v + 1); // 7

    // JSON / string
    console.log(`${count}`); // "7"
    console.log(JSON.stringify(count)); // 7

    // Reactivity
    const unsub = count.sub(() => console.log("changed to", count.get()));
    count.set(8); // triggers subscriber
    unsub();