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

    Type Alias SignalEntry<Type>

    The read/write/subscribe surface shared by every signal. SignalBox adds the ergonomic wrappers on top of this.

    const count: SignalEntry<number> = signal(0);
    const unsub = count.sub(() => console.log("count:", count.get()));
    count.set(1); // logs "count: 1"
    count.update(c => c + 1); // logs "count: 2"
    unsub();
    type SignalEntry<Type = any> = {
        get(): Type;
        set(value: Type): void;
        update(updater: (previous: Type) => Type): void;
        sub(fn: SignalSubscriber): () => void;
        emit(): void;
    }

    Type Parameters

    • Type = any

      The type of the value held by the signal.

    Index
    • Read the current value.

      Returns Type

    • Store a new value. Subscribers run only if the value actually changed.

      Parameters

      Returns void

    • Store a new value derived from the previous one.

      Parameters

      Returns void

    • Subscribe to change notifications. Returns a function that unsubscribes.

      Parameters

      • fn: SignalSubscriber

      Returns () => void

    • Notify subscribers without changing the value. Use it after mutating structural data in place, which set cannot detect.

      Returns void