count
count(
proxied):ValueRef<number>
Defined in: aberdeen.ts:1280
Reactively counts the number of properties in an object.
Parameters
Section titled “Parameters”proxied
Section titled “proxied”TargetType
The observable object to count. In case an array, Map, or Set is passed in, a ref to its .length or .size will be returned.
Returns
Section titled “Returns”ValueRef<number>
an observable object for which the value property reflects the number of properties in proxied with a value other than undefined, or the collection size for arrays, Maps, and Sets.
Example
Section titled “Example”const $items = A.proxy({x: 3, y: 7} as any);const $count = A.count($items);
// Create a DOM text node for the count:A('div text=', $count);// <div>2</div>
// Or we can use it in an {@link derive} function:A(() => console.log("The count is now", $count.value));// The count is now 2
// Adding/removing items will update the count$items.z = 12;// Asynchronously, after 0ms:// <div>3</div>// The count is now 3