Aberdeen - v1.0.3
    Preparing search index...

    Function count

    • Reactively counts the number of properties in an objects.

      Parameters

      • proxied: TargetType

        The observable object to count. In case an array is passed in, a ref to its .length will be returned.

      Returns ValueRef<number>

      an observable object for which the value property reflects the number of properties in proxied with a value other than undefined.

      const items = proxy({x: 3, y: 7} as any);
      const cnt = count(items);

      // Create a DOM text node for the count:
      $('div', {text: cnt});
      // <div>2</div>

      // Or we can use it in an {@link observe} function:
      observe(() => console.log("The count is now", cnt.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