SignalFunction type
Home > @rimitive/signals > SignalFunction
SignalFunction type
Section titled “SignalFunction type”Signal function type - a callable that acts as both getter and setter.
Call with no arguments to read, call with a value to write. Use .peek() to read without tracking dependencies.
Signature:
export type SignalFunction<T> = Writable<T> & { peek(): T;};References: Writable
Example
Section titled “Example”const count: SignalFunction<number> = signal(0);
count(); // read: 0count(5); // writecount(); // read: 5count.peek(); // read without tracking: 5