Reactive type
Home > @rimitive/signals > Reactive
Reactive type
Section titled “Reactive type”Union type for any reactive value (readable or writable).
Use this when a function accepts either signals or computeds.
Signature:
export type Reactive<T> = Readable<T> | Writable<T>;References: Readable, Writable
Example
Section titled “Example”// Function that works with any reactive valuefunction double(source: Reactive<number>): Readable<number> { return computed(() => source() * 2);}
const count = signal(5);const doubled = double(count); // Works with signal
const derived = computed(() => count() + 1);const derivedDoubled = double(derived); // Works with computed too