Skip to content

SignalFunction type

Home > @rimitive/signals > SignalFunction

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

const count: SignalFunction<number> = signal(0);
count(); // read: 0
count(5); // write
count(); // read: 5
count.peek(); // read without tracking: 5