Reactively maps items from a source proxy (array or object) to a target proxied object,
where each source item can contribute multiple key-value pairs to the target.
It iterates over the target proxy. For each item, it calls func.
If func returns an object, all key-value pairs from that object are added to the result proxy.
If func returns undefined, the item contributes nothing.
The returned proxy automatically updates when:
Items are added/removed/updated in the target proxy.
Any proxied data read within the func call changes (for a specific item).
If multiple input items produce the same output key, the last one processed usually "wins",
but the exact behavior on collision depends on update timing.
This is useful for "flattening" or "indexing" data, or converting an observable array to an observable object.
Param: source
The source proxied array or object.
Param: func
A function (value, key) => ({...pairs} | undefined) that transforms an item
into an object of key-value pairs to add, or undefined to add nothing.
Returns
A new proxied object containing the aggregated key-value pairs.
Template: IN
The type of items in the source proxy.
Template: OUT
The type of the aggregated output object (should encompass all possible key-value pairs).
Reactively maps items from a source proxy (array or object) to a target proxied object, where each source item can contribute multiple key-value pairs to the target.
It iterates over the
target
proxy. For each item, it callsfunc
.func
returns an object, all key-value pairs from that object are added to the result proxy.func
returnsundefined
, the item contributes nothing.The returned proxy automatically updates when:
target
proxy.func
call changes (for a specific item).This is useful for "flattening" or "indexing" data, or converting an observable array to an observable object.
Param: source
The source proxied array or object.
Param: func
A function
(value, key) => ({...pairs} | undefined)
that transforms an item into an object of key-value pairs to add, orundefined
to add nothing.Returns
A new proxied object containing the aggregated key-value pairs.
Template: IN
The type of items in the source proxy.
Template: OUT
The type of the aggregated output object (should encompass all possible key-value pairs).
Example: Creating an index from an array