Skip to content
Source
Sign inSign up
TanStack/store
Open History to see the last commit

ReadonlyStore.md

122 lines1.6 KB

1---
2id: ReadonlyStore
3title: ReadonlyStore
4---
5​
6Defined in: [store.ts:59](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L59)
7​
8## Type Parameters
9​
10### T
11​
12`T`
13​
14## Implements
15​
16- `Omit`\<[`Store`](Store.md)\<`T`\>, `"setState"` \| `"actions"`\>
17​
18## Constructors
19​
20### Constructor
21​
22```ts
23new ReadonlyStore<T>(getValue): ReadonlyStore<T>;
24```
25​
26Defined in: [store.ts:64](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L64)
27​
28#### Parameters
29​
30##### getValue
31​
32(`prev?`) => `T`
33​
34#### Returns
35​
36`ReadonlyStore`\<`T`\>
37​
38### Constructor
39​
40```ts
41new ReadonlyStore<T>(initialValue): ReadonlyStore<T>;
42```
43​
44Defined in: [store.ts:65](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L65)
45​
46#### Parameters
47​
48##### initialValue
49​
50`T`
51​
52#### Returns
53​
54`ReadonlyStore`\<`T`\>
55​
56## Accessors
57​
58### state
59​
60#### Get Signature
61​
62```ts
63get state(): T;
64```
65​
66Defined in: [store.ts:73](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L73)
67​
68##### Returns
69​
70`T`
71​
72#### Implementation of
73​
74```ts
75Omit.state
76```
77​
78## Methods
79​
80### get()
81​
82```ts
83get(): T;
84```
85​
86Defined in: [store.ts:76](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L76)
87​
88#### Returns
89​
90`T`
91​
92#### Implementation of
93​
94```ts
95Omit.get
96```
97​
98***
99​
100### subscribe()
101​
102```ts
103subscribe(observerOrFn): Subscription;
104```
105​
106Defined in: [store.ts:79](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L79)
107​
108#### Parameters
109​
110##### observerOrFn
111​
112[`Observer`](../type-aliases/Observer.md)\<`T`\> \| ((`value`) => `void`)
113​
114#### Returns
115​
116[`Subscription`](../interfaces/Subscription.md)
117​
118#### Implementation of
119​
120```ts
121Omit.subscribe
122```