@choksheak/react-utils 0.1.5 → 0.1.7

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.
Files changed (58) hide show
  1. package/docs/assets/navigation.js +1 -1
  2. package/docs/assets/search.js +1 -1
  3. package/docs/classes/sharedQuery.SharedQuery.html +15 -0
  4. package/docs/classes/sharedState.SharedState.html +8 -0
  5. package/docs/classes/sharedState.SharedStateConfig.html +7 -6
  6. package/docs/classes/utils_storage.InMemoryStorageAdapter.html +9 -0
  7. package/docs/classes/utils_storage.IndexedDbAdapter.html +9 -0
  8. package/docs/classes/utils_storage.LocalStorageAdapter.html +9 -0
  9. package/docs/functions/sharedQuery.sharedQuery.html +5 -0
  10. package/docs/functions/sharedQuery.useQuery.html +4 -0
  11. package/docs/functions/sharedState.sharedState.html +2 -2
  12. package/docs/functions/sharedState.useSharedState.html +2 -2
  13. package/docs/functions/sharedState.useSharedStateSetter.html +2 -2
  14. package/docs/functions/sharedState.useSharedStateValue.html +2 -2
  15. package/docs/functions/utils_storage.getStorageAdapter.html +1 -0
  16. package/docs/functions/utils_stringify.stringifyDeterministicForKeys.html +7 -0
  17. package/docs/modules/sharedQuery.html +1 -0
  18. package/docs/modules/sharedState.html +1 -1
  19. package/docs/modules/utils_storage.html +1 -0
  20. package/docs/modules/utils_stringify.html +1 -0
  21. package/docs/modules.html +1 -1
  22. package/docs/types/sharedQuery.FetchFn.html +1 -0
  23. package/docs/types/sharedQuery.FetchedData.html +3 -0
  24. package/docs/types/sharedQuery.QueryStateValue.html +4 -0
  25. package/docs/types/sharedQuery.SharedQueryOptions.html +1 -0
  26. package/docs/types/sharedQuery.SharedQueryState.html +3 -0
  27. package/docs/types/sharedState.SharedStateOptions.html +1 -0
  28. package/docs/types/utils_storage.StorageAdapter.html +5 -0
  29. package/docs/types/utils_storage.StorageOptions.html +5 -0
  30. package/docs/variables/fetcher.fetcher.html +1 -1
  31. package/docs/variables/fetcher.fetcherWithRetries.html +1 -1
  32. package/package.json +9 -6
  33. package/sharedQuery.d.mts +61 -0
  34. package/sharedQuery.d.ts +58 -0
  35. package/sharedQuery.js +471 -0
  36. package/sharedQuery.mjs +444 -0
  37. package/sharedState.d.mts +22 -16
  38. package/sharedState.d.ts +20 -15
  39. package/sharedState.js +157 -85
  40. package/sharedState.mjs +156 -85
  41. package/src/sharedQuery.ts +303 -0
  42. package/src/sharedState.ts +75 -137
  43. package/src/utils/storage.ts +197 -0
  44. package/src/utils/stringify.test.ts +38 -0
  45. package/src/utils/stringify.ts +49 -0
  46. package/utils/storage.d.mts +46 -0
  47. package/utils/storage.d.ts +44 -0
  48. package/utils/storage.js +162 -0
  49. package/utils/storage.mjs +134 -0
  50. package/utils/stringify.d.mts +12 -0
  51. package/utils/stringify.d.ts +10 -0
  52. package/utils/stringify.js +58 -0
  53. package/utils/stringify.mjs +33 -0
  54. package/utils/stringify.test.d.mts +2 -0
  55. package/utils/stringify.test.d.ts +2 -0
  56. package/utils/stringify.test.js +64 -0
  57. package/utils/stringify.test.mjs +81 -0
  58. package/docs/types/sharedState.SharedState.html +0 -6
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/stringify.ts
21
+ var stringify_exports = {};
22
+ __export(stringify_exports, {
23
+ stringifyDeterministicForKeys: () => stringifyDeterministicForKeys
24
+ });
25
+ module.exports = __toCommonJS(stringify_exports);
26
+ function stringifyDeterministicForKeys(params) {
27
+ const cache = /* @__PURE__ */ new Set();
28
+ return JSON.stringify(params, (_, value) => {
29
+ if (typeof value === "function") {
30
+ throw new Error(`Functions should not be passed into query parameters`);
31
+ }
32
+ if (!value || typeof value !== "object") {
33
+ return value;
34
+ }
35
+ if (cache.has(value)) {
36
+ return "[Circular]";
37
+ }
38
+ cache.add(value);
39
+ if (value !== params) {
40
+ try {
41
+ JSON.stringify(value);
42
+ } catch {
43
+ return "[Unserializable]";
44
+ }
45
+ }
46
+ return Object.keys(value).sort().reduce(
47
+ (result, key) => {
48
+ result[key] = value[key];
49
+ return result;
50
+ },
51
+ {}
52
+ );
53
+ });
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ stringifyDeterministicForKeys
58
+ });
@@ -0,0 +1,33 @@
1
+ // src/utils/stringify.ts
2
+ function stringifyDeterministicForKeys(params) {
3
+ const cache = /* @__PURE__ */ new Set();
4
+ return JSON.stringify(params, (_, value) => {
5
+ if (typeof value === "function") {
6
+ throw new Error(`Functions should not be passed into query parameters`);
7
+ }
8
+ if (!value || typeof value !== "object") {
9
+ return value;
10
+ }
11
+ if (cache.has(value)) {
12
+ return "[Circular]";
13
+ }
14
+ cache.add(value);
15
+ if (value !== params) {
16
+ try {
17
+ JSON.stringify(value);
18
+ } catch {
19
+ return "[Unserializable]";
20
+ }
21
+ }
22
+ return Object.keys(value).sort().reduce(
23
+ (result, key) => {
24
+ result[key] = value[key];
25
+ return result;
26
+ },
27
+ {}
28
+ );
29
+ });
30
+ }
31
+ export {
32
+ stringifyDeterministicForKeys
33
+ };
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ // src/utils/stringify.ts
4
+ function stringifyDeterministicForKeys(params) {
5
+ const cache = /* @__PURE__ */ new Set();
6
+ return JSON.stringify(params, (_, value) => {
7
+ if (typeof value === "function") {
8
+ throw new Error(`Functions should not be passed into query parameters`);
9
+ }
10
+ if (!value || typeof value !== "object") {
11
+ return value;
12
+ }
13
+ if (cache.has(value)) {
14
+ return "[Circular]";
15
+ }
16
+ cache.add(value);
17
+ if (value !== params) {
18
+ try {
19
+ JSON.stringify(value);
20
+ } catch {
21
+ return "[Unserializable]";
22
+ }
23
+ }
24
+ return Object.keys(value).sort().reduce(
25
+ (result, key) => {
26
+ result[key] = value[key];
27
+ return result;
28
+ },
29
+ {}
30
+ );
31
+ });
32
+ }
33
+
34
+ // src/utils/stringify.test.ts
35
+ describe("stringifyDeterministicForKeys", () => {
36
+ test("happy", () => {
37
+ const expected = `{"a":1,"b":2,"c":{"e":1,"f":2}}`;
38
+ const actual1 = stringifyDeterministicForKeys({
39
+ a: 1,
40
+ b: 2,
41
+ c: { e: 1, f: 2 }
42
+ });
43
+ expect(actual1).toBe(expected);
44
+ const actual2 = stringifyDeterministicForKeys({
45
+ c: { f: 2, e: 1 },
46
+ b: 2,
47
+ a: 1
48
+ });
49
+ expect(actual2).toBe(expected);
50
+ });
51
+ test("circular", () => {
52
+ const circular = { b: {}, a: 1 };
53
+ circular.b = circular;
54
+ const actual = stringifyDeterministicForKeys(circular);
55
+ expect(actual).toBe(`{"a":1,"b":"[Circular]"}`);
56
+ });
57
+ test("function", () => {
58
+ const fn = { b: {}, a: () => {
59
+ } };
60
+ expect(() => stringifyDeterministicForKeys(fn)).toThrow(
61
+ `Functions should not be passed into query parameters`
62
+ );
63
+ });
64
+ });
@@ -0,0 +1,81 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ };
5
+ var __commonJS = (cb, mod) => function __require() {
6
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
+ };
8
+
9
+ // src/utils/stringify.ts
10
+ function stringifyDeterministicForKeys(params) {
11
+ const cache = /* @__PURE__ */ new Set();
12
+ return JSON.stringify(params, (_, value) => {
13
+ if (typeof value === "function") {
14
+ throw new Error(`Functions should not be passed into query parameters`);
15
+ }
16
+ if (!value || typeof value !== "object") {
17
+ return value;
18
+ }
19
+ if (cache.has(value)) {
20
+ return "[Circular]";
21
+ }
22
+ cache.add(value);
23
+ if (value !== params) {
24
+ try {
25
+ JSON.stringify(value);
26
+ } catch {
27
+ return "[Unserializable]";
28
+ }
29
+ }
30
+ return Object.keys(value).sort().reduce(
31
+ (result, key) => {
32
+ result[key] = value[key];
33
+ return result;
34
+ },
35
+ {}
36
+ );
37
+ });
38
+ }
39
+ var init_stringify = __esm({
40
+ "src/utils/stringify.ts"() {
41
+ "use strict";
42
+ }
43
+ });
44
+
45
+ // src/utils/stringify.test.ts
46
+ var require_stringify_test = __commonJS({
47
+ "src/utils/stringify.test.ts"() {
48
+ init_stringify();
49
+ describe("stringifyDeterministicForKeys", () => {
50
+ test("happy", () => {
51
+ const expected = `{"a":1,"b":2,"c":{"e":1,"f":2}}`;
52
+ const actual1 = stringifyDeterministicForKeys({
53
+ a: 1,
54
+ b: 2,
55
+ c: { e: 1, f: 2 }
56
+ });
57
+ expect(actual1).toBe(expected);
58
+ const actual2 = stringifyDeterministicForKeys({
59
+ c: { f: 2, e: 1 },
60
+ b: 2,
61
+ a: 1
62
+ });
63
+ expect(actual2).toBe(expected);
64
+ });
65
+ test("circular", () => {
66
+ const circular = { b: {}, a: 1 };
67
+ circular.b = circular;
68
+ const actual = stringifyDeterministicForKeys(circular);
69
+ expect(actual).toBe(`{"a":1,"b":"[Circular]"}`);
70
+ });
71
+ test("function", () => {
72
+ const fn = { b: {}, a: () => {
73
+ } };
74
+ expect(() => stringifyDeterministicForKeys(fn)).toThrow(
75
+ `Functions should not be passed into query parameters`
76
+ );
77
+ });
78
+ });
79
+ }
80
+ });
81
+ export default require_stringify_test();
@@ -1,6 +0,0 @@
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>SharedState | 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">SharedState</a></li></ul><h1>Type Alias SharedState&lt;T&gt;</h1></div><div class="tsd-signature"><span class="tsd-signature-keyword">type</span> <span class="tsd-kind-type-alias">SharedState</span><span class="tsd-signature-symbol">&lt;</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#t">T</a><span class="tsd-signature-symbol">&gt;</span> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-symbol">{</span><br/>    <a class="tsd-kind-property" href="#getsnapshot">getSnapshot</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">()</span> <span class="tsd-signature-symbol">=&gt;</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#t">T</a><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#initdefaultvalueonce">initDefaultValueOnce</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">()</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#initdone">initDone</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#setvalue">setValue</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">next</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-kind-parameter">prev</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">=&gt;</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">=&gt;</span> <span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#subscribe">subscribe</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">subscriber</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">()</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-symbol">()</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">void</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/efa963a701b271796802dd1d38f3336450c46cc7/src/sharedState.ts#L107">sharedState.ts:107</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="#getsnapshot" 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>get<wbr/>Snapshot</span></a>
2
- <a href="#initdefaultvalueonce" 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>init<wbr/>Default<wbr/>Value<wbr/>Once</span></a>
3
- <a href="#initdone" 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>init<wbr/>Done</span></a>
4
- <a href="#setvalue" 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>set<wbr/>Value</span></a>
5
- <a href="#subscribe" 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>subscribe</span></a>
6
- </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="getsnapshot"><span>get<wbr/>Snapshot</span><a href="#getsnapshot" 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">getSnapshot</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">()</span> <span class="tsd-signature-symbol">=&gt;</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#t">T</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/efa963a701b271796802dd1d38f3336450c46cc7/src/sharedState.ts#L109">sharedState.ts:109</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="initdefaultvalueonce"><span>init<wbr/>Default<wbr/>Value<wbr/>Once</span><a href="#initdefaultvalueonce" 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">initDefaultValueOnce</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">()</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">void</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/efa963a701b271796802dd1d38f3336450c46cc7/src/sharedState.ts#L110">sharedState.ts:110</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="initdone"><span>init<wbr/>Done</span><a href="#initdone" 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">initDone</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/efa963a701b271796802dd1d38f3336450c46cc7/src/sharedState.ts#L111">sharedState.ts:111</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="setvalue"><span>set<wbr/>Value</span><a href="#setvalue" 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">setValue</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">next</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-kind-parameter">prev</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">=&gt;</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">=&gt;</span> <span class="tsd-signature-type">void</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/efa963a701b271796802dd1d38f3336450c46cc7/src/sharedState.ts#L112">sharedState.ts:112</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="subscribe"><span>subscribe</span><a href="#subscribe" 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">subscribe</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">subscriber</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">()</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-symbol">()</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">void</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/efa963a701b271796802dd1d38f3336450c46cc7/src/sharedState.ts#L108">sharedState.ts:108</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="#getsnapshot"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>get<wbr/>Snapshot</span></a><a href="#initdefaultvalueonce"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>init<wbr/>Default<wbr/>Value<wbr/>Once</span></a><a href="#initdone"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>init<wbr/>Done</span></a><a href="#setvalue"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>set<wbr/>Value</span></a><a href="#subscribe"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>subscribe</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>