react-declarative-docs / documents /docs_api_hooks_collection-hooks.html
tripolskypetr's picture
patch
9375fc1
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>docs/api/hooks/collection-hooks | react-declarative</title><meta name="description" content="Documentation for react-declarative"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">react-declarative</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">react-declarative</a></li><li><a href="docs_api_hooks_collection-hooks.html">docs/api/hooks/collection-hooks</a></li></ul></div><div class="tsd-panel tsd-typography"><a id="collection-hooks-usecollection-usemodel-useentity" class="tsd-anchor"></a><h1 class="tsd-anchor-link">Collection hooks: useCollection, useModel, useEntity<a href="#collection-hooks-usecollection-usemodel-useentity" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h1><p>Collection hooks give you fine-grained, observable reactive state built on the MVVM pattern. Rather than replacing a full state array on every change, these hooks operate on internal <code>Collection</code>, <code>Model</code>, and <code>Entity</code> instances and only trigger re-renders when the underlying data actually changes. All mutation methods are async and wait for the component to be mounted and subscribed before applying changes, preventing race conditions during React 18's concurrent rendering.</p>
<a id="usecollection" class="tsd-anchor"></a><h2 class="tsd-anchor-link">useCollection<a href="#usecollection" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Creates and manages a <strong>reactive, observable array</strong> of entities. Each entity in the collection must have a unique <code>id</code> field. The hook returns a <code>CollectionAdapter</code> with methods for adding, updating, removing, finding, and iterating items. Changes to the collection trigger an <code>onChange</code> callback and re-render only the components that actually use the changed data.</p>
<a id="signature" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Signature<a href="#signature" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="ts"><span class="hl-4">interface</span><span class="hl-1"> </span><span class="hl-7">IEntity</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">id</span><span class="hl-1">: </span><span class="hl-7">string</span><span class="hl-1"> | </span><span class="hl-7">number</span><span class="hl-1">;</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">useCollection</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1"> </span><span class="hl-4">extends</span><span class="hl-1"> </span><span class="hl-7">IEntity</span><span class="hl-1">&gt;(</span><span class="hl-2">options</span><span class="hl-1">?: {</span><br/><span class="hl-1"> </span><span class="hl-2">initialValue</span><span class="hl-1">?: </span><span class="hl-7">T</span><span class="hl-1">[] | (() </span><span class="hl-4">=&gt;</span><span class="hl-1"> </span><span class="hl-7">T</span><span class="hl-1">[]) | </span><span class="hl-7">Entity</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt;[] | </span><span class="hl-7">Collection</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt;;</span><br/><span class="hl-1"> </span><span class="hl-5">onChange</span><span class="hl-1">?: (</span><span class="hl-2">collection</span><span class="hl-1">: </span><span class="hl-7">CollectionAdapter</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt;, </span><span class="hl-2">target</span><span class="hl-1">: </span><span class="hl-7">CollectionEntityAdapter</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt; | </span><span class="hl-7">null</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> </span><span class="hl-7">void</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">debounce</span><span class="hl-1">?: </span><span class="hl-7">number</span><span class="hl-1">;</span><br/><span class="hl-1">}): </span><span class="hl-7">CollectionAdapter</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt;</span>
</code><button type="button">Copy</button></pre>
<a id="parameters" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Parameters<a href="#parameters" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p><strong><code>options.initialValue</code></strong> (<code>T[] | (() =&gt; T[]) | Collection&lt;T&gt;</code>, default: <code>[]</code>)</p>
<p>The starting data for the collection. Accepts a plain array, a factory function, or an existing <code>Collection</code> instance.</p>
<p><strong><code>options.onChange</code></strong> (<code>(collection, target) =&gt; void</code>)</p>
<p>Called whenever the collection changes. <code>collection</code> is the current <code>CollectionAdapter</code>; <code>target</code> is the <code>CollectionEntityAdapter</code> for the specific entity that changed, or <code>null</code> for bulk operations.</p>
<p><strong><code>options.debounce</code></strong> (<code>number</code>)</p>
<p>Debounce delay in milliseconds for batching rapid successive changes before triggering a re-render. Defaults to the library's <code>CHANGE_DEBOUNCE</code> constant.</p>
<a id="collectionadapter-methods" class="tsd-anchor"></a><h3 class="tsd-anchor-link">CollectionAdapter methods<a href="#collectionadapter-methods" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The object returned by <code>useCollection</code> is a <code>CollectionAdapter&lt;T&gt;</code> with the following API:</p>
<table>
<thead>
<tr>
<th>Method / Property</th>
<th>Signature</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>ids</code></td>
<td><code>(string | number)[]</code></td>
<td>Array of all entity IDs in insertion order.</td>
</tr>
<tr>
<td><code>isEmpty</code></td>
<td><code>boolean</code></td>
<td><code>true</code> when the collection has no items.</td>
</tr>
<tr>
<td><code>push</code></td>
<td><code>(...items: T[] | T[][]) =&gt; Promise&lt;void&gt;</code></td>
<td>Appends one or more new entities.</td>
</tr>
<tr>
<td><code>upsert</code></td>
<td><code>(...items: T[] | T[][]) =&gt; Promise&lt;void&gt;</code></td>
<td>Inserts entities that don't exist yet; updates those that do (matched by <code>id</code>).</td>
</tr>
<tr>
<td><code>remove</code></td>
<td><code>(entity: IEntity) =&gt; Promise&lt;void&gt;</code></td>
<td>Removes a specific entity object.</td>
</tr>
<tr>
<td><code>removeById</code></td>
<td><code>(id: string | number) =&gt; Promise&lt;void&gt;</code></td>
<td>Removes an entity by ID.</td>
</tr>
<tr>
<td><code>removeAll</code></td>
<td><code>() =&gt; Promise&lt;void&gt;</code></td>
<td>Removes every entity.</td>
</tr>
<tr>
<td><code>clear</code></td>
<td><code>() =&gt; Promise&lt;void&gt;</code></td>
<td>Clears the collection (same as <code>removeAll</code>).</td>
</tr>
<tr>
<td><code>setData</code></td>
<td><code>(items: T[]) =&gt; Promise&lt;void&gt;</code></td>
<td>Replaces the entire collection with a new array.</td>
</tr>
<tr>
<td><code>findById</code></td>
<td><code>(id) =&gt; CollectionEntityAdapter&lt;T&gt;</code></td>
<td>Returns a reactive adapter for a specific entity.</td>
</tr>
<tr>
<td><code>find</code></td>
<td><code>(fn) =&gt; CollectionEntityAdapter&lt;T&gt; | undefined</code></td>
<td>Array-style <code>find</code>.</td>
</tr>
<tr>
<td><code>filter</code></td>
<td><code>(fn) =&gt; CollectionEntityAdapter&lt;T&gt;[]</code></td>
<td>Array-style <code>filter</code>.</td>
</tr>
<tr>
<td><code>map</code></td>
<td><code>&lt;V&gt;(fn) =&gt; V[]</code></td>
<td>Array-style <code>map</code>.</td>
</tr>
<tr>
<td><code>some</code></td>
<td><code>(fn) =&gt; boolean</code></td>
<td>Array-style <code>some</code>.</td>
</tr>
<tr>
<td><code>forEach</code></td>
<td><code>(fn) =&gt; void</code></td>
<td>Array-style <code>forEach</code>.</td>
</tr>
<tr>
<td><code>toArray</code></td>
<td><code>() =&gt; T[]</code></td>
<td>Returns a plain snapshot of all entity data.</td>
</tr>
<tr>
<td><code>refresh</code></td>
<td><code>() =&gt; Promise&lt;void&gt;</code></td>
<td>Forces a re-render of subscribers without changing data.</td>
</tr>
</tbody>
</table>
<p>Each item yielded by <code>find</code>, <code>filter</code>, <code>map</code>, and <code>forEach</code> is a <code>CollectionEntityAdapter&lt;T&gt;</code> exposing:</p>
<ul>
<li><code>id</code> — the entity's ID</li>
<li><code>data</code> — current data snapshot</li>
<li><code>setData(partial | fn)</code> — update just this entity's fields</li>
<li><code>toObject()</code> — plain object snapshot</li>
<li><code>refresh()</code> — force a re-render for this entity</li>
</ul>
<a id="usage" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Usage<a href="#usage" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="tsx"><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">useCollection</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;react-declarative&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-4">interface</span><span class="hl-1"> </span><span class="hl-7">Counter</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">id</span><span class="hl-1">: </span><span class="hl-7">string</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">name</span><span class="hl-1">: </span><span class="hl-7">string</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">value</span><span class="hl-1">: </span><span class="hl-7">number</span><span class="hl-1">;</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">CounterList</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-10">collection</span><span class="hl-1"> = </span><span class="hl-5">useCollection</span><span class="hl-1">&lt;</span><span class="hl-7">Counter</span><span class="hl-1">&gt;({</span><br/><span class="hl-1"> </span><span class="hl-5">onChange</span><span class="hl-2">:</span><span class="hl-1"> (</span><span class="hl-2">collection</span><span class="hl-1">, </span><span class="hl-2">target</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><br/><span class="hl-1"> </span><span class="hl-2">console</span><span class="hl-1">.</span><span class="hl-5">log</span><span class="hl-1">(</span><span class="hl-3">&#39;changed&#39;</span><span class="hl-1">, { </span><span class="hl-2">collection</span><span class="hl-1">, </span><span class="hl-2">target</span><span class="hl-1"> }),</span><br/><span class="hl-1"> </span><span class="hl-2">initialValue:</span><span class="hl-1"> [],</span><br/><span class="hl-1"> });</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">handleAdd</span><span class="hl-1"> = </span><span class="hl-4">async</span><span class="hl-1"> () </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> { </span><span class="hl-10">id</span><span class="hl-1">, ...</span><span class="hl-10">data</span><span class="hl-1"> } = </span><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-5">fetchApi</span><span class="hl-1">(</span><span class="hl-3">&#39;/api/v1/counters/create&#39;</span><span class="hl-1">, {</span><br/><span class="hl-1"> </span><span class="hl-2">method:</span><span class="hl-1"> </span><span class="hl-3">&#39;POST&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-2">collection</span><span class="hl-1">.</span><span class="hl-5">push</span><span class="hl-1">({ </span><span class="hl-2">id</span><span class="hl-1">, ...</span><span class="hl-2">data</span><span class="hl-1"> });</span><br/><span class="hl-1"> };</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">handleUpsert</span><span class="hl-1"> = </span><span class="hl-4">async</span><span class="hl-1"> () </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-10">updatedItems</span><span class="hl-1"> = </span><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-5">fetchApi</span><span class="hl-1">(</span><span class="hl-3">&#39;/api/v1/counters/list&#39;</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-2">collection</span><span class="hl-1">.</span><span class="hl-5">upsert</span><span class="hl-1">(</span><span class="hl-2">updatedItems</span><span class="hl-1">);</span><br/><span class="hl-1"> };</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">handleRemove</span><span class="hl-1"> = </span><span class="hl-4">async</span><span class="hl-1"> (</span><span class="hl-2">id</span><span class="hl-1">: </span><span class="hl-7">string</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-2">collection</span><span class="hl-1">.</span><span class="hl-5">removeById</span><span class="hl-1">(</span><span class="hl-2">id</span><span class="hl-1">);</span><br/><span class="hl-1"> };</span><br/><br/><span class="hl-1"> </span><span class="hl-0">return</span><span class="hl-1"> (</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">button</span><span class="hl-1"> </span><span class="hl-8">onClick</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-2">handleAdd</span><span class="hl-4">}</span><span class="hl-6">&gt;</span><span class="hl-1">Add item</span><span class="hl-6">&lt;/</span><span class="hl-18">button</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">button</span><span class="hl-1"> </span><span class="hl-8">onClick</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-2">handleUpsert</span><span class="hl-4">}</span><span class="hl-6">&gt;</span><span class="hl-1">Sync from server</span><span class="hl-6">&lt;/</span><span class="hl-18">button</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">ul</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-4">{</span><span class="hl-2">collection</span><span class="hl-9">.</span><span class="hl-5">map</span><span class="hl-9">((</span><span class="hl-2">entity</span><span class="hl-9">) </span><span class="hl-4">=&gt;</span><span class="hl-9"> (</span><br/><span class="hl-9"> </span><span class="hl-6">&lt;</span><span class="hl-18">li</span><span class="hl-9"> </span><span class="hl-8">key</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-2">entity</span><span class="hl-9">.</span><span class="hl-2">id</span><span class="hl-4">}</span><span class="hl-6">&gt;</span><br/><span class="hl-9"> </span><span class="hl-4">{</span><span class="hl-2">entity</span><span class="hl-9">.</span><span class="hl-2">data</span><span class="hl-9">.</span><span class="hl-2">name</span><span class="hl-4">}</span><span class="hl-9">: </span><span class="hl-4">{</span><span class="hl-2">entity</span><span class="hl-9">.</span><span class="hl-2">data</span><span class="hl-9">.</span><span class="hl-2">value</span><span class="hl-4">}</span><br/><span class="hl-9"> </span><span class="hl-6">&lt;</span><span class="hl-18">button</span><span class="hl-9"> </span><span class="hl-8">onClick</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-9">() </span><span class="hl-4">=&gt;</span><span class="hl-9"> </span><span class="hl-5">handleRemove</span><span class="hl-9">(</span><span class="hl-5">String</span><span class="hl-9">(</span><span class="hl-2">entity</span><span class="hl-9">.</span><span class="hl-2">id</span><span class="hl-9">))</span><span class="hl-4">}</span><span class="hl-6">&gt;</span><br/><span class="hl-9"> Remove</span><br/><span class="hl-9"> </span><span class="hl-6">&lt;/</span><span class="hl-18">button</span><span class="hl-6">&gt;</span><br/><span class="hl-9"> </span><span class="hl-6">&lt;/</span><span class="hl-18">li</span><span class="hl-6">&gt;</span><br/><span class="hl-9"> ))</span><span class="hl-4">}</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;/</span><span class="hl-18">ul</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;/&gt;</span><br/><span class="hl-1"> );</span><br/><span class="hl-1">}</span>
</code><button type="button">Copy</button></pre>
<a id="entity-level-updates" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Entity-level updates<a href="#entity-level-updates" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p>You can update a specific entity without replacing the whole collection:</p>
<pre><code class="tsx"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-10">entity</span><span class="hl-1"> = </span><span class="hl-2">collection</span><span class="hl-1">.</span><span class="hl-5">findById</span><span class="hl-1">(</span><span class="hl-2">targetId</span><span class="hl-1">);</span><br/><br/><span class="hl-17">// Merge a partial update</span><br/><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-2">entity</span><span class="hl-1">.</span><span class="hl-5">setData</span><span class="hl-1">({ </span><span class="hl-2">value:</span><span class="hl-1"> </span><span class="hl-2">entity</span><span class="hl-1">.</span><span class="hl-2">data</span><span class="hl-1">.</span><span class="hl-2">value</span><span class="hl-1"> + </span><span class="hl-16">1</span><span class="hl-1"> });</span><br/><br/><span class="hl-17">// Or use a function for safe increments</span><br/><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-2">entity</span><span class="hl-1">.</span><span class="hl-5">setData</span><span class="hl-1">((</span><span class="hl-2">prev</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> ({ </span><span class="hl-2">value:</span><span class="hl-1"> </span><span class="hl-2">prev</span><span class="hl-1">.</span><span class="hl-2">value</span><span class="hl-1"> + </span><span class="hl-16">1</span><span class="hl-1"> }));</span>
</code><button type="button">Copy</button></pre>
<hr>
<a id="usemodel" class="tsd-anchor"></a><h2 class="tsd-anchor-link">useModel<a href="#usemodel" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Creates and manages a <strong>single reactive object</strong>. When you call <code>setData</code> on the returned <code>ModelAdapter</code>, the component re-renders with the new state and <code>onChange</code> is called. Use this for form state, page-level settings, or any single plain object you want to observe reactively.</p>
<a id="signature-1" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Signature<a href="#signature-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="ts"><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">useModel</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1"> </span><span class="hl-4">extends</span><span class="hl-1"> {}&gt;(</span><span class="hl-2">options</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-2">initialValue</span><span class="hl-1">: </span><span class="hl-7">T</span><span class="hl-1"> | </span><span class="hl-7">Model</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt; | (() </span><span class="hl-4">=&gt;</span><span class="hl-1"> </span><span class="hl-7">T</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-5">onChange</span><span class="hl-1">?: (</span><span class="hl-2">model</span><span class="hl-1">: </span><span class="hl-7">ModelAdapter</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt;) </span><span class="hl-4">=&gt;</span><span class="hl-1"> </span><span class="hl-7">void</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">debounce</span><span class="hl-1">?: </span><span class="hl-7">number</span><span class="hl-1">;</span><br/><span class="hl-1">}): </span><span class="hl-7">ModelAdapter</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt;</span>
</code><button type="button">Copy</button></pre>
<a id="parameters-1" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Parameters<a href="#parameters-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p><strong><code>options.initialValue</code></strong> (<code>T | Model&lt;T&gt; | (() =&gt; T)</code>, required)</p>
<p>Starting value for the model. Accepts a plain object, factory function, or an existing <code>Model</code> instance.</p>
<p><strong><code>options.onChange</code></strong> (<code>(model: ModelAdapter&lt;T&gt;) =&gt; void</code>)</p>
<p>Called whenever the model data changes.</p>
<p><strong><code>options.debounce</code></strong> (<code>number</code>)</p>
<p>Debounce delay in milliseconds before triggering a re-render after a change. Defaults to <code>CHANGE_DEBOUNCE</code>.</p>
<a id="modeladapter-methods" class="tsd-anchor"></a><h3 class="tsd-anchor-link">ModelAdapter methods<a href="#modeladapter-methods" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><table>
<thead>
<tr>
<th>Method / Property</th>
<th>Signature</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>data</code></td>
<td><code>T</code></td>
<td>Current data snapshot.</td>
</tr>
<tr>
<td><code>setData</code></td>
<td><code>(partial | fn) =&gt; Promise&lt;void&gt;</code></td>
<td>Merges a partial update or applies a function that receives the previous state and returns a partial.</td>
</tr>
<tr>
<td><code>refresh</code></td>
<td><code>() =&gt; Promise&lt;void&gt;</code></td>
<td>Forces a re-render without changing data.</td>
</tr>
<tr>
<td><code>toObject</code></td>
<td><code>() =&gt; T</code></td>
<td>Returns a plain object snapshot of the current data.</td>
</tr>
<tr>
<td><code>toModel</code></td>
<td><code>() =&gt; Model&lt;T&gt;</code></td>
<td>Returns the underlying <code>Model</code> instance.</td>
</tr>
</tbody>
</table>
<a id="usage-1" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Usage<a href="#usage-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="tsx"><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">useModel</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;react-declarative&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-4">interface</span><span class="hl-1"> </span><span class="hl-7">FilterState</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">search</span><span class="hl-1">: </span><span class="hl-7">string</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">status</span><span class="hl-1">: </span><span class="hl-3">&#39;all&#39;</span><span class="hl-1"> | </span><span class="hl-3">&#39;active&#39;</span><span class="hl-1"> | </span><span class="hl-3">&#39;archived&#39;</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">page</span><span class="hl-1">: </span><span class="hl-7">number</span><span class="hl-1">;</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">FilterBar</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-10">model</span><span class="hl-1"> = </span><span class="hl-5">useModel</span><span class="hl-1">&lt;</span><span class="hl-7">FilterState</span><span class="hl-1">&gt;({</span><br/><span class="hl-1"> </span><span class="hl-2">initialValue:</span><span class="hl-1"> { </span><span class="hl-2">search:</span><span class="hl-1"> </span><span class="hl-3">&#39;&#39;</span><span class="hl-1">, </span><span class="hl-2">status:</span><span class="hl-1"> </span><span class="hl-3">&#39;all&#39;</span><span class="hl-1">, </span><span class="hl-2">page:</span><span class="hl-1"> </span><span class="hl-16">1</span><span class="hl-1"> },</span><br/><span class="hl-1"> </span><span class="hl-5">onChange</span><span class="hl-2">:</span><span class="hl-1"> (</span><span class="hl-2">m</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> </span><span class="hl-5">fetchResults</span><span class="hl-1">(</span><span class="hl-2">m</span><span class="hl-1">.</span><span class="hl-2">data</span><span class="hl-1">),</span><br/><span class="hl-1"> });</span><br/><br/><span class="hl-1"> </span><span class="hl-0">return</span><span class="hl-1"> (</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">div</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">input</span><br/><span class="hl-1"> </span><span class="hl-8">value</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-2">model</span><span class="hl-9">.</span><span class="hl-2">data</span><span class="hl-9">.</span><span class="hl-2">search</span><span class="hl-4">}</span><br/><span class="hl-1"> </span><span class="hl-8">onChange</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-9">(</span><span class="hl-2">e</span><span class="hl-9">) </span><span class="hl-4">=&gt;</span><span class="hl-9"> </span><span class="hl-2">model</span><span class="hl-9">.</span><span class="hl-5">setData</span><span class="hl-9">({ </span><span class="hl-2">search:</span><span class="hl-9"> </span><span class="hl-2">e</span><span class="hl-9">.</span><span class="hl-2">target</span><span class="hl-9">.</span><span class="hl-2">value</span><span class="hl-9">, </span><span class="hl-2">page:</span><span class="hl-9"> </span><span class="hl-16">1</span><span class="hl-9"> })</span><span class="hl-4">}</span><br/><span class="hl-1"> </span><span class="hl-8">placeholder</span><span class="hl-1">=</span><span class="hl-3">&quot;Search…&quot;</span><br/><span class="hl-1"> </span><span class="hl-6">/&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">select</span><br/><span class="hl-1"> </span><span class="hl-8">value</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-2">model</span><span class="hl-9">.</span><span class="hl-2">data</span><span class="hl-9">.</span><span class="hl-2">status</span><span class="hl-4">}</span><br/><span class="hl-1"> </span><span class="hl-8">onChange</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-9">(</span><span class="hl-2">e</span><span class="hl-9">) </span><span class="hl-4">=&gt;</span><br/><span class="hl-9"> </span><span class="hl-2">model</span><span class="hl-9">.</span><span class="hl-5">setData</span><span class="hl-9">({ </span><span class="hl-2">status:</span><span class="hl-9"> </span><span class="hl-2">e</span><span class="hl-9">.</span><span class="hl-2">target</span><span class="hl-9">.</span><span class="hl-2">value</span><span class="hl-9"> </span><span class="hl-0">as</span><span class="hl-9"> </span><span class="hl-7">FilterState</span><span class="hl-9">[</span><span class="hl-3">&#39;status&#39;</span><span class="hl-9">], </span><span class="hl-2">page:</span><span class="hl-9"> </span><span class="hl-16">1</span><span class="hl-9"> })</span><br/><span class="hl-9"> </span><span class="hl-4">}</span><br/><span class="hl-1"> </span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">option</span><span class="hl-1"> </span><span class="hl-8">value</span><span class="hl-1">=</span><span class="hl-3">&quot;all&quot;</span><span class="hl-6">&gt;</span><span class="hl-1">All</span><span class="hl-6">&lt;/</span><span class="hl-18">option</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">option</span><span class="hl-1"> </span><span class="hl-8">value</span><span class="hl-1">=</span><span class="hl-3">&quot;active&quot;</span><span class="hl-6">&gt;</span><span class="hl-1">Active</span><span class="hl-6">&lt;/</span><span class="hl-18">option</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">option</span><span class="hl-1"> </span><span class="hl-8">value</span><span class="hl-1">=</span><span class="hl-3">&quot;archived&quot;</span><span class="hl-6">&gt;</span><span class="hl-1">Archived</span><span class="hl-6">&lt;/</span><span class="hl-18">option</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;/</span><span class="hl-18">select</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;/</span><span class="hl-18">div</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> );</span><br/><span class="hl-1">}</span>
</code><button type="button">Copy</button></pre>
<hr>
<a id="useentity" class="tsd-anchor"></a><h2 class="tsd-anchor-link">useEntity<a href="#useentity" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Creates and manages a <strong>single reactive entity</strong> — like <code>useModel</code> but designed for records that carry an <code>id</code> field. The returned <code>EntityAdapter</code> exposes the <code>id</code> getter alongside the standard <code>data</code> and <code>setData</code> API, making it the right choice when the thing you're observing is a database record or any named, identifiable object.</p>
<a id="signature-2" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Signature<a href="#signature-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="ts"><span class="hl-4">interface</span><span class="hl-1"> </span><span class="hl-7">IEntity</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">id</span><span class="hl-1">: </span><span class="hl-7">string</span><span class="hl-1"> | </span><span class="hl-7">number</span><span class="hl-1">;</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">useEntity</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1"> </span><span class="hl-4">extends</span><span class="hl-1"> </span><span class="hl-7">IEntity</span><span class="hl-1">&gt;(</span><span class="hl-2">options</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-2">initialValue</span><span class="hl-1">: </span><span class="hl-7">T</span><span class="hl-1"> | </span><span class="hl-7">Entity</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt; | (() </span><span class="hl-4">=&gt;</span><span class="hl-1"> </span><span class="hl-7">T</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-5">onChange</span><span class="hl-1">?: (</span><span class="hl-2">entity</span><span class="hl-1">: </span><span class="hl-7">EntityAdapter</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt;) </span><span class="hl-4">=&gt;</span><span class="hl-1"> </span><span class="hl-7">void</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">debounce</span><span class="hl-1">?: </span><span class="hl-7">number</span><span class="hl-1">;</span><br/><span class="hl-1">}): </span><span class="hl-7">EntityAdapter</span><span class="hl-1">&lt;</span><span class="hl-7">T</span><span class="hl-1">&gt;</span>
</code><button type="button">Copy</button></pre>
<a id="parameters-2" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Parameters<a href="#parameters-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p><strong><code>options.initialValue</code></strong> (<code>T | Entity&lt;T&gt; | (() =&gt; T)</code>, required)</p>
<p>Starting value. Must include an <code>id</code> field.</p>
<p><strong><code>options.onChange</code></strong> (<code>(entity: EntityAdapter&lt;T&gt;) =&gt; void</code>)</p>
<p>Called whenever the entity data changes.</p>
<p><strong><code>options.debounce</code></strong> (<code>number</code>)</p>
<p>Debounce delay in milliseconds. Defaults to <code>CHANGE_DEBOUNCE</code>.</p>
<a id="entityadapter-methods" class="tsd-anchor"></a><h3 class="tsd-anchor-link">EntityAdapter methods<a href="#entityadapter-methods" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><table>
<thead>
<tr>
<th>Method / Property</th>
<th>Signature</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>id</code></td>
<td><code>string | number</code></td>
<td>The entity's ID.</td>
</tr>
<tr>
<td><code>data</code></td>
<td><code>T</code></td>
<td>Current data snapshot.</td>
</tr>
<tr>
<td><code>setData</code></td>
<td><code>(partial | fn) =&gt; Promise&lt;void&gt;</code></td>
<td>Merges a partial update or applies a functional update.</td>
</tr>
<tr>
<td><code>refresh</code></td>
<td><code>() =&gt; Promise&lt;void&gt;</code></td>
<td>Forces a re-render without changing data.</td>
</tr>
<tr>
<td><code>toObject</code></td>
<td><code>() =&gt; T</code></td>
<td>Returns a plain object snapshot.</td>
</tr>
<tr>
<td><code>toEntity</code></td>
<td><code>() =&gt; Entity&lt;T&gt;</code></td>
<td>Returns the underlying <code>Entity</code> instance.</td>
</tr>
</tbody>
</table>
<a id="usage-2" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Usage<a href="#usage-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="tsx"><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">useEntity</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;react-declarative&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-4">interface</span><span class="hl-1"> </span><span class="hl-7">Product</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">id</span><span class="hl-1">: </span><span class="hl-7">string</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">name</span><span class="hl-1">: </span><span class="hl-7">string</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">price</span><span class="hl-1">: </span><span class="hl-7">number</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-2">inStock</span><span class="hl-1">: </span><span class="hl-7">boolean</span><span class="hl-1">;</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">ProductCard</span><span class="hl-1">({ </span><span class="hl-2">initial</span><span class="hl-1"> }: { </span><span class="hl-2">initial</span><span class="hl-1">: </span><span class="hl-7">Product</span><span class="hl-1"> }) {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-10">entity</span><span class="hl-1"> = </span><span class="hl-5">useEntity</span><span class="hl-1">&lt;</span><span class="hl-7">Product</span><span class="hl-1">&gt;({</span><br/><span class="hl-1"> </span><span class="hl-2">initialValue:</span><span class="hl-1"> </span><span class="hl-2">initial</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">onChange</span><span class="hl-2">:</span><span class="hl-1"> (</span><span class="hl-2">e</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> </span><span class="hl-2">api</span><span class="hl-1">.</span><span class="hl-5">saveProduct</span><span class="hl-1">(</span><span class="hl-2">e</span><span class="hl-1">.</span><span class="hl-5">toObject</span><span class="hl-1">()),</span><br/><span class="hl-1"> });</span><br/><br/><span class="hl-1"> </span><span class="hl-0">return</span><span class="hl-1"> (</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">div</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">h2</span><span class="hl-6">&gt;</span><span class="hl-4">{</span><span class="hl-2">entity</span><span class="hl-9">.</span><span class="hl-2">data</span><span class="hl-9">.</span><span class="hl-2">name</span><span class="hl-4">}</span><span class="hl-6">&lt;/</span><span class="hl-18">h2</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">p</span><span class="hl-6">&gt;</span><span class="hl-1">$</span><span class="hl-4">{</span><span class="hl-2">entity</span><span class="hl-9">.</span><span class="hl-2">data</span><span class="hl-9">.</span><span class="hl-2">price</span><span class="hl-4">}</span><span class="hl-6">&lt;/</span><span class="hl-18">p</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">label</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-18">input</span><br/><span class="hl-1"> </span><span class="hl-8">type</span><span class="hl-1">=</span><span class="hl-3">&quot;checkbox&quot;</span><br/><span class="hl-1"> </span><span class="hl-8">checked</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-2">entity</span><span class="hl-9">.</span><span class="hl-2">data</span><span class="hl-9">.</span><span class="hl-2">inStock</span><span class="hl-4">}</span><br/><span class="hl-1"> </span><span class="hl-8">onChange</span><span class="hl-1">=</span><span class="hl-4">{</span><span class="hl-9">(</span><span class="hl-2">e</span><span class="hl-9">) </span><span class="hl-4">=&gt;</span><span class="hl-9"> </span><span class="hl-2">entity</span><span class="hl-9">.</span><span class="hl-5">setData</span><span class="hl-9">({ </span><span class="hl-2">inStock:</span><span class="hl-9"> </span><span class="hl-2">e</span><span class="hl-9">.</span><span class="hl-2">target</span><span class="hl-9">.</span><span class="hl-2">checked</span><span class="hl-9"> })</span><span class="hl-4">}</span><br/><span class="hl-1"> </span><span class="hl-6">/&gt;</span><br/><span class="hl-1"> In stock</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;/</span><span class="hl-18">label</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;/</span><span class="hl-18">div</span><span class="hl-6">&gt;</span><br/><span class="hl-1"> );</span><br/><span class="hl-1">}</span>
</code><button type="button">Copy</button></pre>
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#collection-hooks-usecollection-usemodel-useentity"><span>Collection hooks: use<wbr/>Collection, use<wbr/>Model, use<wbr/>Entity</span></a><ul><li><a href="#usecollection"><span>use<wbr/>Collection</span></a></li><li><ul><li><a href="#signature"><span>Signature</span></a></li><li><a href="#parameters"><span>Parameters</span></a></li><li><a href="#collectionadapter-methods"><span>Collection<wbr/>Adapter methods</span></a></li><li><a href="#usage"><span>Usage</span></a></li><li><a href="#entity-level-updates"><span>Entity-<wbr/>level updates</span></a></li></ul></li><li><a href="#usemodel"><span>use<wbr/>Model</span></a></li><li><ul><li><a href="#signature-1"><span>Signature</span></a></li><li><a href="#parameters-1"><span>Parameters</span></a></li><li><a href="#modeladapter-methods"><span>Model<wbr/>Adapter methods</span></a></li><li><a href="#usage-1"><span>Usage</span></a></li></ul></li><li><a href="#useentity"><span>use<wbr/>Entity</span></a></li><li><ul><li><a href="#signature-2"><span>Signature</span></a></li><li><a href="#parameters-2"><span>Parameters</span></a></li><li><a href="#entityadapter-methods"><span>Entity<wbr/>Adapter methods</span></a></li><li><a href="#usage-2"><span>Usage</span></a></li></ul></li></ul></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">react-declarative</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>