@choksheak/react-utils 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/sharedQuery.SharedQuery.html +10 -8
- package/docs/classes/sharedState.SharedState.html +2 -2
- package/docs/classes/utils_storage.InMemoryStorageAdapter.html +2 -2
- package/docs/classes/utils_storage.IndexedDbAdapter.html +2 -2
- package/docs/classes/utils_storage.LocalStorageAdapter.html +2 -2
- package/docs/functions/sharedQuery.sharedQuery.html +2 -2
- package/docs/functions/sharedQuery.useSharedQuery.html +4 -0
- package/docs/functions/sharedState.sharedState.html +1 -1
- package/docs/functions/sharedState.useSharedState.html +1 -1
- package/docs/functions/sharedState.useSharedStateSetter.html +1 -1
- package/docs/functions/sharedState.useSharedStateValue.html +1 -1
- package/docs/functions/utils_storage.getStorageAdapter.html +1 -1
- package/docs/functions/utils_stringify.stringifyDeterministicForKeys.html +1 -1
- package/docs/modules/sharedQuery.html +1 -1
- package/docs/modules/sharedState.html +1 -1
- package/docs/types/sharedQuery.FetchFn.html +1 -1
- package/docs/types/sharedQuery.PersistTo.html +1 -0
- package/docs/types/sharedQuery.QueryStateValue.html +5 -3
- package/docs/types/sharedQuery.SharedQueryOptions.html +1 -1
- package/docs/types/sharedQuery.SharedQueryState.html +2 -2
- package/docs/types/sharedQuery.UseQueryResult.html +1 -0
- package/docs/types/sharedState.SharedStateOptions.html +1 -1
- package/docs/types/utils_storage.StorageAdapter.html +2 -2
- package/docs/types/utils_storage.StorageOptions.html +2 -2
- package/docs/variables/fetcher.fetcher.html +1 -1
- package/docs/variables/fetcher.fetcherWithRetries.html +1 -1
- package/docs/variables/sharedQuery.SharedQueryDefaults.html +2 -0
- package/docs/variables/sharedState.SharedStateDefaults.html +6 -0
- package/package.json +8 -1
- package/sharedQuery.d.mts +48 -33
- package/sharedQuery.d.ts +46 -32
- package/sharedQuery.js +120 -95
- package/sharedQuery.mjs +119 -95
- package/sharedState.d.mts +5 -5
- package/sharedState.d.ts +4 -4
- package/sharedState.js +10 -8
- package/sharedState.mjs +9 -7
- package/src/sharedQuery.ts +181 -131
- package/src/sharedState.ts +10 -7
- package/docs/classes/sharedState.SharedStateConfig.html +0 -9
- package/docs/functions/sharedQuery.useQuery.html +0 -4
- package/docs/types/sharedQuery.FetchedData.html +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>StorageOptions | Chok’s React Utilities</title><meta name="description" content="Documentation for Chok’s React Utilities"/><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></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Chok’s React Utilities</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" 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></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/utils_storage.html">utils/storage</a></li><li><a href="" aria-current="page">StorageOptions</a></li></ul><h1>Type Alias StorageOptions<T></h1></div><div class="tsd-signature"><span class="tsd-signature-keyword">type</span> <span class="tsd-kind-type-alias">StorageOptions</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#t">T</a><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-symbol">{</span><br/> <a class="tsd-kind-property" href="#indexeddbkey">indexedDbKey</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#localstoragekey">localStorageKey</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#store">store</a><span class="tsd-signature-symbol">?:</span> <a href="utils_storage.StorageAdapter.html" class="tsd-signature-type tsd-kind-type-alias">StorageAdapter</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#t">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#storeexpiryms">storeExpiryMs</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="t"><span class="tsd-kind-type-parameter">T</span></span></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>StorageOptions | Chok’s React Utilities</title><meta name="description" content="Documentation for Chok’s React Utilities"/><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></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Chok’s React Utilities</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" 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></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/utils_storage.html">utils/storage</a></li><li><a href="" aria-current="page">StorageOptions</a></li></ul><h1>Type Alias StorageOptions<T></h1></div><div class="tsd-signature"><span class="tsd-signature-keyword">type</span> <span class="tsd-kind-type-alias">StorageOptions</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#t">T</a><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-symbol">{</span><br/> <a class="tsd-kind-property" href="#indexeddbkey">indexedDbKey</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#localstoragekey">localStorageKey</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#store">store</a><span class="tsd-signature-symbol">?:</span> <a href="utils_storage.StorageAdapter.html" class="tsd-signature-type tsd-kind-type-alias">StorageAdapter</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#t">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#storeexpiryms">storeExpiryMs</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="t"><span class="tsd-kind-type-parameter">T</span></span></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/utils/storage.ts#L10">utils/storage.ts:10</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="#indexeddbkey" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>indexed<wbr/>Db<wbr/>Key?</span></a>
|
|
2
2
|
<a href="#localstoragekey" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>local<wbr/>Storage<wbr/>Key?</span></a>
|
|
3
3
|
<a href="#store" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>store?</span></a>
|
|
4
4
|
<a href="#storeexpiryms" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>store<wbr/>Expiry<wbr/>Ms?</span></a>
|
|
5
|
-
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Properties</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="indexeddbkey"><code class="tsd-tag">Optional</code><span>indexed<wbr/>Db<wbr/>Key</span><a href="#indexeddbkey" 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><div class="tsd-signature"><span class="tsd-kind-property">indexedDbKey</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/
|
|
5
|
+
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Properties</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="indexeddbkey"><code class="tsd-tag">Optional</code><span>indexed<wbr/>Db<wbr/>Key</span><a href="#indexeddbkey" 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><div class="tsd-signature"><span class="tsd-kind-property">indexedDbKey</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/utils/storage.ts#L18">utils/storage.ts:18</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="localstoragekey"><code class="tsd-tag">Optional</code><span>local<wbr/>Storage<wbr/>Key</span><a href="#localstoragekey" 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><div class="tsd-signature"><span class="tsd-kind-property">localStorageKey</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/utils/storage.ts#L15">utils/storage.ts:15</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="store"><code class="tsd-tag">Optional</code><span>store</span><a href="#store" 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><div class="tsd-signature"><span class="tsd-kind-property">store</span><span class="tsd-signature-symbol">?:</span> <a href="utils_storage.StorageAdapter.html" class="tsd-signature-type tsd-kind-type-alias">StorageAdapter</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#t">T</a><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/utils/storage.ts#L12">utils/storage.ts:12</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="storeexpiryms"><code class="tsd-tag">Optional</code><span>store<wbr/>Expiry<wbr/>Ms</span><a href="#storeexpiryms" 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><div class="tsd-signature"><span class="tsd-kind-property">storeExpiryMs</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/utils/storage.ts#L21">utils/storage.ts:21</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#indexeddbkey"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>indexed<wbr/>Db<wbr/>Key</span></a><a href="#localstoragekey"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>local<wbr/>Storage<wbr/>Key</span></a><a href="#store"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>store</span></a><a href="#storeexpiryms"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>store<wbr/>Expiry<wbr/>Ms</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Chok’s React Utilities</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>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>fetcher | Chok’s React Utilities</title><meta name="description" content="Documentation for Chok’s React Utilities"/><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></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Chok’s React Utilities</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" 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></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/fetcher.html">fetcher</a></li><li><a href="" aria-current="page">fetcher</a></li></ul><h1>Variable fetcher<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">fetcher</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Wretch</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> = ...</span></div><div class="tsd-comment tsd-typography"><p>Name this as "fetcher" to make it easier to understand.</p>
|
|
2
|
-
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/
|
|
2
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/fetcher.ts#L5">fetcher.ts:5</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Chok’s React Utilities</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>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>fetcherWithRetries | Chok’s React Utilities</title><meta name="description" content="Documentation for Chok’s React Utilities"/><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></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Chok’s React Utilities</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" 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></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/fetcher.html">fetcher</a></li><li><a href="" aria-current="page">fetcherWithRetries</a></li></ul><h1>Variable fetcherWithRetries<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">fetcherWithRetries</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Wretch</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> = ...</span></div><div class="tsd-comment tsd-typography"><p>Fetcher with default short retries.</p>
|
|
2
|
-
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/
|
|
2
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/fetcher.ts#L8">fetcher.ts:8</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Chok’s React Utilities</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>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>SharedQueryDefaults | Chok’s React Utilities</title><meta name="description" content="Documentation for Chok’s React Utilities"/><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></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Chok’s React Utilities</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" 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></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/sharedQuery.html">sharedQuery</a></li><li><a href="" aria-current="page">SharedQueryDefaults</a></li></ul><h1>Variable SharedQueryDefaults<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">SharedQueryDefaults</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">expiryMs</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">persistTo</span><span class="tsd-signature-symbol">:</span> <a href="../types/sharedQuery.PersistTo.html" class="tsd-signature-type tsd-kind-type-alias">PersistTo</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">staleMs</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = ...</span></div><div class="tsd-comment tsd-typography"><p>Users can override these values globally.</p>
|
|
2
|
+
</div><div class="tsd-type-declaration"><h4>Type Declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter"><h5 id="expiryms"><span class="tsd-kind-property">expiryMs</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></h5></li><li class="tsd-parameter"><h5 id="persistto"><span class="tsd-kind-property">persistTo</span><span class="tsd-signature-symbol">: </span><a href="../types/sharedQuery.PersistTo.html" class="tsd-signature-type tsd-kind-type-alias">PersistTo</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span></h5></li><li class="tsd-parameter"><h5 id="stalems"><span class="tsd-kind-property">staleMs</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></h5></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/sharedQuery.ts#L62">sharedQuery.ts:62</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Chok’s React Utilities</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>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>SharedStateDefaults | Chok’s React Utilities</title><meta name="description" content="Documentation for Chok’s React Utilities"/><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></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Chok’s React Utilities</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" 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></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/sharedState.html">sharedState</a></li><li><a href="" aria-current="page">SharedStateDefaults</a></li></ul><h1>Variable SharedStateDefaults<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">SharedStateDefaults</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">lazyLoad</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">storeExpiryMs</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = ...</span></div><div class="tsd-comment tsd-typography"><p>These values are configurable by the user at any time.</p>
|
|
2
|
+
</div><div class="tsd-type-declaration"><h4>Type Declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter"><h5 id="lazyload"><span class="tsd-kind-property">lazyLoad</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>True to load from storage only on mount, false (default) to load in
|
|
3
|
+
the top level scope when the shared state is defined.</p>
|
|
4
|
+
</div></li><li class="tsd-parameter"><h5 id="storeexpiryms"><span class="tsd-kind-property">storeExpiryMs</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><p>Default duration for storage expiration in milliseconds. Initial value
|
|
5
|
+
is 30 days, but can be changed to anything.</p>
|
|
6
|
+
</div></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/sharedState.ts#L28">sharedState.ts:28</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Chok’s React Utilities</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>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@choksheak/react-utils",
|
|
3
3
|
"license": "The Unlicense",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"description": "Miscellaneous React+TypeScript utilities with support for full tree-shaking.",
|
|
6
6
|
"private": false,
|
|
7
7
|
"main": "index.js",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./fetcher.d.ts",
|
|
17
17
|
"import": "./fetcher.js"
|
|
18
18
|
},
|
|
19
|
+
"./sharedQuery": {
|
|
20
|
+
"types": "./sharedQuery.d.ts",
|
|
21
|
+
"import": "./sharedQuery.js"
|
|
22
|
+
},
|
|
19
23
|
"./sharedState": {
|
|
20
24
|
"types": "./sharedState.d.ts",
|
|
21
25
|
"import": "./sharedState.js"
|
|
@@ -26,6 +30,9 @@
|
|
|
26
30
|
"fetcher": [
|
|
27
31
|
"fetcher.d.ts"
|
|
28
32
|
],
|
|
33
|
+
"sharedQuery": [
|
|
34
|
+
"sharedQuery.d.ts"
|
|
35
|
+
],
|
|
29
36
|
"sharedState": [
|
|
30
37
|
"sharedState.d.ts"
|
|
31
38
|
]
|
package/sharedQuery.d.mts
CHANGED
|
@@ -1,47 +1,62 @@
|
|
|
1
|
-
import { SharedState } from './sharedState.mjs';
|
|
2
|
-
import
|
|
1
|
+
import { SharedStateOptions, SharedState } from './sharedState.mjs';
|
|
2
|
+
import './utils/storage.mjs';
|
|
3
3
|
|
|
4
|
-
type FetchFn<TArgs extends unknown[],
|
|
5
|
-
type
|
|
6
|
-
value: TResult;
|
|
7
|
-
updatedMs: number;
|
|
8
|
-
};
|
|
9
|
-
type QueryStateValue<TResult> = {
|
|
10
|
-
data: FetchedData<TResult> | null;
|
|
4
|
+
type FetchFn<TArgs extends unknown[], TData> = (...args: TArgs) => Promise<TData> | TData;
|
|
5
|
+
type QueryStateValue<TData> = {
|
|
11
6
|
loading: boolean;
|
|
12
|
-
|
|
7
|
+
data?: TData;
|
|
8
|
+
dataUpdatedMs?: number;
|
|
9
|
+
error?: Error;
|
|
10
|
+
errorUpdatedMs?: number;
|
|
11
|
+
};
|
|
12
|
+
type UseQueryResult<TData> = QueryStateValue<TData> & {
|
|
13
|
+
refetch: () => Promise<TData>;
|
|
14
|
+
setData: (data: TData, dataUpdatedMs?: number) => void;
|
|
15
|
+
deleteData: () => void;
|
|
13
16
|
};
|
|
17
|
+
type PersistTo = "localStorage" | "indexedDb";
|
|
14
18
|
/**
|
|
15
|
-
* The full query state is a record of all the fetch
|
|
19
|
+
* The full query state is a record of all the fetch states mapped by
|
|
16
20
|
* query key to the state entry.
|
|
17
21
|
*/
|
|
18
|
-
type SharedQueryState<
|
|
19
|
-
type SharedQueryOptions<
|
|
22
|
+
type SharedQueryState<TData> = Record<string, QueryStateValue<TData>>;
|
|
23
|
+
type SharedQueryOptions<TArgs extends unknown[], TData> = {
|
|
24
|
+
queryName: string;
|
|
25
|
+
queryFn: FetchFn<TArgs, TData>;
|
|
20
26
|
staleMs?: number;
|
|
21
27
|
expiryMs?: number;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
refetchOnStale?: boolean;
|
|
29
|
+
persistTo?: PersistTo;
|
|
30
|
+
} & SharedStateOptions<SharedQueryState<TData>>;
|
|
31
|
+
/** Users can override these values globally. */
|
|
32
|
+
declare const SharedQueryDefaults: {
|
|
33
|
+
staleMs: number;
|
|
34
|
+
expiryMs: number;
|
|
35
|
+
persistTo: PersistTo | undefined;
|
|
36
|
+
};
|
|
37
|
+
declare class SharedQuery<TArgs extends unknown[], TData> {
|
|
27
38
|
private readonly inflightPromises;
|
|
28
|
-
readonly queryState: SharedState<SharedQueryState<
|
|
39
|
+
readonly queryState: SharedState<SharedQueryState<TData>>;
|
|
40
|
+
readonly queryName: string;
|
|
41
|
+
private readonly queryFn;
|
|
29
42
|
readonly expiryMs: number;
|
|
30
43
|
readonly staleMs: number;
|
|
31
|
-
readonly
|
|
32
|
-
constructor(
|
|
44
|
+
readonly refetchOnStale: boolean;
|
|
45
|
+
constructor(options: SharedQueryOptions<TArgs, TData>);
|
|
33
46
|
getQueryKey(args: TArgs): string;
|
|
34
47
|
private isStale;
|
|
35
48
|
private isExpired;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
private
|
|
49
|
+
getCachedOrFetch(...args: TArgs): Promise<TData>;
|
|
50
|
+
private dedupedFetch;
|
|
51
|
+
private startFetching;
|
|
52
|
+
/** Set the data directly if the user obtained it from somewhere else. */
|
|
53
|
+
setData(queryKey: string, data: TData, dataUpdatedMs?: number): Promise<void>;
|
|
39
54
|
/** Do a new fetch even when the data is already cached. */
|
|
40
|
-
updateFromSource(...args: TArgs): Promise<
|
|
41
|
-
/** Delete the
|
|
42
|
-
|
|
43
|
-
/** Delete
|
|
44
|
-
|
|
55
|
+
updateFromSource(...args: TArgs): Promise<TData>;
|
|
56
|
+
/** Delete the cached data for one set of arguments. */
|
|
57
|
+
deleteData(args: TArgs): void;
|
|
58
|
+
/** Delete all currently cached data & all inflight promises. */
|
|
59
|
+
clear(): void;
|
|
45
60
|
}
|
|
46
61
|
/**
|
|
47
62
|
* Create a reusable shared query object that can be used to auto de-duplicate
|
|
@@ -50,12 +65,12 @@ declare class SharedQuery<TArgs extends unknown[], TResult> {
|
|
|
50
65
|
* Each `queryName` must be unique, and can only be declared once, most often
|
|
51
66
|
* in the top level scope. The queryName is used for logging only.
|
|
52
67
|
*/
|
|
53
|
-
declare function sharedQuery<TArgs extends unknown[],
|
|
68
|
+
declare function sharedQuery<TArgs extends unknown[], TData>(options: SharedQueryOptions<TArgs, TData>): SharedQuery<TArgs, TData>;
|
|
54
69
|
/**
|
|
55
70
|
* React hook to make use of a shared query inside any React component.
|
|
56
71
|
*
|
|
57
|
-
* const users =
|
|
72
|
+
* const users = useSharedQuery(usersQuery, ["123"]);
|
|
58
73
|
*/
|
|
59
|
-
declare function
|
|
74
|
+
declare function useSharedQuery<TArgs extends unknown[], TData>(query: SharedQuery<TArgs, TData>, args?: TArgs): UseQueryResult<TData>;
|
|
60
75
|
|
|
61
|
-
export { type FetchFn, type
|
|
76
|
+
export { type FetchFn, type PersistTo, type QueryStateValue, SharedQuery, SharedQueryDefaults, type SharedQueryOptions, type SharedQueryState, type UseQueryResult, sharedQuery, useSharedQuery };
|
package/sharedQuery.d.ts
CHANGED
|
@@ -1,46 +1,60 @@
|
|
|
1
|
-
import { SharedState } from "./sharedState";
|
|
2
|
-
|
|
3
|
-
export type
|
|
4
|
-
export type FetchedData<TResult> = {
|
|
5
|
-
value: TResult;
|
|
6
|
-
updatedMs: number;
|
|
7
|
-
};
|
|
8
|
-
export type QueryStateValue<TResult> = {
|
|
9
|
-
data: FetchedData<TResult> | null;
|
|
1
|
+
import { SharedState, SharedStateOptions } from "./sharedState";
|
|
2
|
+
export type FetchFn<TArgs extends unknown[], TData> = (...args: TArgs) => Promise<TData> | TData;
|
|
3
|
+
export type QueryStateValue<TData> = {
|
|
10
4
|
loading: boolean;
|
|
11
|
-
|
|
5
|
+
data?: TData;
|
|
6
|
+
dataUpdatedMs?: number;
|
|
7
|
+
error?: Error;
|
|
8
|
+
errorUpdatedMs?: number;
|
|
9
|
+
};
|
|
10
|
+
export type UseQueryResult<TData> = QueryStateValue<TData> & {
|
|
11
|
+
refetch: () => Promise<TData>;
|
|
12
|
+
setData: (data: TData, dataUpdatedMs?: number) => void;
|
|
13
|
+
deleteData: () => void;
|
|
12
14
|
};
|
|
15
|
+
export type PersistTo = "localStorage" | "indexedDb";
|
|
13
16
|
/**
|
|
14
|
-
* The full query state is a record of all the fetch
|
|
17
|
+
* The full query state is a record of all the fetch states mapped by
|
|
15
18
|
* query key to the state entry.
|
|
16
19
|
*/
|
|
17
|
-
export type SharedQueryState<
|
|
18
|
-
export type SharedQueryOptions<
|
|
20
|
+
export type SharedQueryState<TData> = Record<string, QueryStateValue<TData>>;
|
|
21
|
+
export type SharedQueryOptions<TArgs extends unknown[], TData> = {
|
|
22
|
+
queryName: string;
|
|
23
|
+
queryFn: FetchFn<TArgs, TData>;
|
|
19
24
|
staleMs?: number;
|
|
20
25
|
expiryMs?: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
refetchOnStale?: boolean;
|
|
27
|
+
persistTo?: PersistTo;
|
|
28
|
+
} & SharedStateOptions<SharedQueryState<TData>>;
|
|
29
|
+
/** Users can override these values globally. */
|
|
30
|
+
export declare const SharedQueryDefaults: {
|
|
31
|
+
staleMs: number;
|
|
32
|
+
expiryMs: number;
|
|
33
|
+
persistTo: PersistTo | undefined;
|
|
34
|
+
};
|
|
35
|
+
export declare class SharedQuery<TArgs extends unknown[], TData> {
|
|
26
36
|
private readonly inflightPromises;
|
|
27
|
-
readonly queryState: SharedState<SharedQueryState<
|
|
37
|
+
readonly queryState: SharedState<SharedQueryState<TData>>;
|
|
38
|
+
readonly queryName: string;
|
|
39
|
+
private readonly queryFn;
|
|
28
40
|
readonly expiryMs: number;
|
|
29
41
|
readonly staleMs: number;
|
|
30
|
-
readonly
|
|
31
|
-
constructor(
|
|
42
|
+
readonly refetchOnStale: boolean;
|
|
43
|
+
constructor(options: SharedQueryOptions<TArgs, TData>);
|
|
32
44
|
getQueryKey(args: TArgs): string;
|
|
33
45
|
private isStale;
|
|
34
46
|
private isExpired;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
private
|
|
47
|
+
getCachedOrFetch(...args: TArgs): Promise<TData>;
|
|
48
|
+
private dedupedFetch;
|
|
49
|
+
private startFetching;
|
|
50
|
+
/** Set the data directly if the user obtained it from somewhere else. */
|
|
51
|
+
setData(queryKey: string, data: TData, dataUpdatedMs?: number): Promise<void>;
|
|
38
52
|
/** Do a new fetch even when the data is already cached. */
|
|
39
|
-
updateFromSource(...args: TArgs): Promise<
|
|
40
|
-
/** Delete the
|
|
41
|
-
|
|
42
|
-
/** Delete
|
|
43
|
-
|
|
53
|
+
updateFromSource(...args: TArgs): Promise<TData>;
|
|
54
|
+
/** Delete the cached data for one set of arguments. */
|
|
55
|
+
deleteData(args: TArgs): void;
|
|
56
|
+
/** Delete all currently cached data & all inflight promises. */
|
|
57
|
+
clear(): void;
|
|
44
58
|
}
|
|
45
59
|
/**
|
|
46
60
|
* Create a reusable shared query object that can be used to auto de-duplicate
|
|
@@ -49,10 +63,10 @@ export declare class SharedQuery<TArgs extends unknown[], TResult> {
|
|
|
49
63
|
* Each `queryName` must be unique, and can only be declared once, most often
|
|
50
64
|
* in the top level scope. The queryName is used for logging only.
|
|
51
65
|
*/
|
|
52
|
-
export declare function sharedQuery<TArgs extends unknown[],
|
|
66
|
+
export declare function sharedQuery<TArgs extends unknown[], TData>(options: SharedQueryOptions<TArgs, TData>): SharedQuery<TArgs, TData>;
|
|
53
67
|
/**
|
|
54
68
|
* React hook to make use of a shared query inside any React component.
|
|
55
69
|
*
|
|
56
|
-
* const users =
|
|
70
|
+
* const users = useSharedQuery(usersQuery, ["123"]);
|
|
57
71
|
*/
|
|
58
|
-
export declare function
|
|
72
|
+
export declare function useSharedQuery<TArgs extends unknown[], TData>(query: SharedQuery<TArgs, TData>, args?: TArgs): UseQueryResult<TData>;
|