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

Store.md

156 lines2.3 KB

1---
2id: Store
3title: Store
4---
5​
6Defined in: [store.ts:15](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L15)
7​
8## Type Parameters
9​
10### T
11​
12`T`
13​
14### TActions
15​
16`TActions` *extends* [`StoreActionMap`](../type-aliases/StoreActionMap.md) = `never`
17​
18## Constructors
19​
20### Constructor
21​
22```ts
23new Store<T, TActions>(getValue): Store<T, TActions>;
24```
25​
26Defined in: [store.ts:18](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L18)
27​
28#### Parameters
29​
30##### getValue
31​
32(`prev?`) => `T`
33​
34#### Returns
35​
36`Store`\<`T`, `TActions`\>
37​
38### Constructor
39​
40```ts
41new Store<T, TActions>(initialValue): Store<T, TActions>;
42```
43​
44Defined in: [store.ts:19](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L19)
45​
46#### Parameters
47​
48##### initialValue
49​
50`T`
51​
52#### Returns
53​
54`Store`\<`T`, `TActions`\>
55​
56### Constructor
57​
58```ts
59new Store<T, TActions>(initialValue, actionsFactory): Store<T, TActions>;
60```
61​
62Defined in: [store.ts:20](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L20)
63​
64#### Parameters
65​
66##### initialValue
67​
68`NonFunction`\<`T`\>
69​
70##### actionsFactory
71​
72[`StoreActionsFactory`](../type-aliases/StoreActionsFactory.md)\<`T`, `TActions`\>
73​
74#### Returns
75​
76`Store`\<`T`, `TActions`\>
77​
78## Properties
79​
80### actions
81​
82```ts
83readonly actions: TActions;
84```
85​
86Defined in: [store.ts:17](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L17)
87​
88## Accessors
89​
90### state
91​
92#### Get Signature
93​
94```ts
95get state(): T;
96```
97​
98Defined in: [store.ts:46](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L46)
99​
100##### Returns
101​
102`T`
103​
104## Methods
105​
106### get()
107​
108```ts
109get(): T;
110```
111​
112Defined in: [store.ts:49](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L49)
113​
114#### Returns
115​
116`T`
117​
118***
119​
120### setState()
121​
122```ts
123setState(updater): void;
124```
125​
126Defined in: [store.ts:43](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L43)
127​
128#### Parameters
129​
130##### updater
131​
132(`prev`) => `T`
133​
134#### Returns
135​
136`void`
137​
138***
139​
140### subscribe()
141​
142```ts
143subscribe(observerOrFn): Subscription;
144```
145​
146Defined in: [store.ts:52](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L52)
147​
148#### Parameters
149​
150##### observerOrFn
151​
152[`Observer`](../type-aliases/Observer.md)\<`T`\> \| ((`value`) => `void`)
153​
154#### Returns
155​
156[`Subscription`](../interfaces/Subscription.md)