createComputed
Creates a computed value that automatically updates when its dependencies change.
Signature
function createComputed<T>(fn: () => T): Signal<T>;Parameters
Returns
Example
const [firstName, setFirstName] = createSignal("John");
const [lastName, setLastName] = createSignal("Doe");
const fullName = createComputed(() => {
return `${firstName()} ${lastName()}`;
});
console.log(fullName()); // "John Doe"
setFirstName("Jane");
console.log(fullName()); // "Jane Doe"Advanced Usage
Behavior
Performance Notes
Last updated