function _createDerivedProperty<T, S>( sources, derive,options?): _ReadonlyReactiveProperty<T>;Creates a derived reactive property from one or more sources.
The value is computed from source values using a derivation function. Updates are memoized (only emit when derived value changes).
Type Parameters#
| Type Parameter |
|---|
T |
S extends any[] |
Parameters#
| Parameter | Type | Description |
|---|---|---|
sources | { [K in string | number |
derive | (…values) => T | Function that computes the derived value from source values |
options? | Pick<_ReactivePropertyOptions<T>, "equals"> | Configuration options |
Returns#
A read-only reactive property
Example#
const width = createReactiveProperty(800);const height = createReactiveProperty(600);
const area = createDerivedProperty( [width, height], (w, h) => w * h);
area.subscribe((value) => console.log('Area:', value));width.update(1000); // Logs: "Area: 600000"