memo
Returns a getter caching the result of fn. Re-evaluates when reactive
dependencies change. See the Reactivity docs for details.
import { memo } from "@alloy-js/core";
function memo<T>(fn: () => T, equal?: boolean, name?: string): () => T;Parameters
Section titled “Parameters”| fn | () => T | |
| equal | optional boolean | |
| name | optional string |
Returns
Section titled “Returns”() => T A zero-argument getter returning the cached value.
Example
Section titled “Example”const fullName = memo(() => `${first.value} ${last.value}`);
fullName(); // cached; re-evaluates when first or last changes