-<span class="punctuation">}</span></code></pre><div class="table"><table><tr><th></th><th>Type</th><th>Description</th></tr><tr><th><code>tables<span class="operator">?</span></code></th><td><code><span class="builtin">number</span></code></td><td><p>The number of TablesListeners registered with the <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p></td></tr><tr><th><code>tableIds<span class="operator">?</span></code></th><td><code><span class="builtin">number</span></code></td><td><p>The number of TableIdsListeners registered with the <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p></td></tr><tr><th><code>table<span class="operator">?</span></code></th><td><code><span class="builtin">number</span></code></td><td><p>The number of TableListeners registered with the <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p></td></tr><tr><th><code>rowIds<span class="operator">?</span></code></th><td><code><span class="builtin">number</span></code></td><td><p>The number of RowIdsListeners registered with the <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p></td></tr><tr><th><code>row<span class="operator">?</span></code></th><td><code><span class="builtin">number</span></code></td><td><p>The number of RowListeners registered with the <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p></td></tr><tr><th><code>cellIds<span class="operator">?</span></code></th><td><code><span class="builtin">number</span></code></td><td><p>The number of CellIdsListeners registered with the <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p></td></tr><tr><th><code>cell<span class="operator">?</span></code></th><td><code><span class="builtin">number</span></code></td><td><p>The number of CellListeners registered with the <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p></td></tr><tr><th><code>invalidCell<span class="operator">?</span></code></th><td><code><span class="builtin">number</span></code></td><td><p>The number of InvalidCellListeners registered with the <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p></td></tr></table></div><p>The <code>StoreListenerStats</code> object contains a breakdown of the different types of listener. Totals include both mutator and non-mutator listeners. A <code>StoreListenerStats</code> object is returned from the getListenerStats method, and is only populated in a debug build.</p></section></section></section></section><section class="s2" id="/api/metrics" data-id="m"><h2><code>metrics</code></h2><p>The <code>metrics</code> module of the <a href="#/">TinyBase</a> project provides the ability to create and track metrics and aggregates of the data in <a href="#/api/store/interfaces/store/store"><code>Store</code></a> objects.</p><p>The main entry point to this module is the <a href="#/api/metrics/functions/creation/createmetrics"><code>createMetrics</code></a> function, which returns a new <a href="#/api/metrics/interfaces/metrics/metrics"><code>Metrics</code></a> object. From there, you can create new <a href="#/api/metrics/type-aliases/metric/metric"><code>Metric</code></a> definitions, access the values of those <a href="#/api/metrics/interfaces/metrics/metrics"><code>Metrics</code></a> directly, and register listeners for when they change.</p><section class="s3" id="/api/metrics/interfaces" data-id="m/0"><h3>Interfaces</h3><p>There is one interface, <a href="#/api/metrics/interfaces/metrics/metrics"><code>Metrics</code></a>, within the <a href="#/api/metrics"><code>metrics</code></a> module.</p><section class="s4" id="/api/metrics/interfaces/metrics/metrics" data-id="M"><h4><code>Metrics</code></h4><p>A <code>Metrics</code> object lets you define, query, and listen to, aggregations of <a href="#/api/store/type-aliases/store/cell"><code>Cell</code></a> values within a <a href="#/api/store/type-aliases/store/table"><code>Table</code></a> in a <a href="#/api/store/interfaces/store/store"><code>Store</code></a>.</p><p>This is useful for counting the number of <a href="#/api/store/type-aliases/store/row"><code>Row</code></a> objects in a <a href="#/api/store/type-aliases/store/table"><code>Table</code></a>, averaging <a href="#/api/store/type-aliases/store/cell"><code>Cell</code></a> values, or efficiently performing any arbitrary aggregations.</p><p>Create a <code>Metrics</code> object easily with the <a href="#/api/metrics/functions/creation/createmetrics"><code>createMetrics</code></a> function. From there, you can add new <a href="#/api/metrics/type-aliases/metric/metric"><code>Metric</code></a> definitions (with the <a href="#/api/metrics/interfaces/metrics/metrics/methods/configuration/setmetricdefinition"><code>setMetricDefinition</code></a> method), query their values (with the <a href="#/api/metrics/interfaces/metrics/metrics/methods/getter/getmetric"><code>getMetric</code></a> method), and add listeners for when they change (with the <a href="#/api/metrics/interfaces/metrics/metrics/methods/listener/addmetriclistener"><code>addMetricListener</code></a> method).</p><p>This module provides a number of predefined and self-explanatory aggregations ('sum', 'avg', 'min', and 'max'), and defaults to counting <a href="#/api/store/type-aliases/store/row"><code>Row</code></a> objects when using the <a href="#/api/metrics/interfaces/metrics/metrics/methods/configuration/setmetricdefinition"><code>setMetricDefinition</code></a> method. However, far more complex aggregations can be configured with custom functions.</p><section class="s5"><h5>Example</h5><p>This example shows a very simple lifecycle of a <code>Metrics</code> object: from creation, to adding a definition, getting an <a href="#/api/metrics/type-aliases/metric/metric"><code>Metric</code></a>, and then registering and removing a listener for it.</p><pre><code><span class="keyword">const</span> store <span class="operator">=</span> <span class="function"><a href="#/api/store/functions/creation/createstore">createStore</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">.</span><span class="function"><a href="#/api/store/interfaces/store/store/methods/setter/settable">setTable</a></span><span class="punctuation">(</span><span class="string">'species'</span><span class="punctuation">,</span> <span class="punctuation">{</span>
0 commit comments