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

store.md

124 lines1.9 KB

1---
2id: Store
3title: Store
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8# Class: Store\<TState, TUpdater\>
9​
10Defined in: [store.ts:27](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L27)
11​
12## Type Parameters
13​
14β€’ **TState**
15​
16β€’ **TUpdater** *extends* `AnyUpdater` = (`cb`) => `TState`
17​
18## Constructors
19​
20### new Store()
21​
22```ts
23new Store<TState, TUpdater>(initialState, options?): Store<TState, TUpdater>
24```
25​
26Defined in: [store.ts:36](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L36)
27​
28#### Parameters
29​
30##### initialState
31​
32`TState`
33​
34##### options?
35​
36[`StoreOptions`](../../interfaces/storeoptions.md)\<`TState`, `TUpdater`\>
37​
38#### Returns
39​
40[`Store`](../store.md)\<`TState`, `TUpdater`\>
41​
42## Properties
43​
44### listeners
45​
46```ts
47listeners: Set<Listener<TState>>;
48```
49​
50Defined in: [store.ts:31](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L31)
51​
52***
53​
54### options?
55​
56```ts
57optional options: StoreOptions<TState, TUpdater>;
58```
59​
60Defined in: [store.ts:34](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L34)
61​
62***
63​
64### prevState
65​
66```ts
67prevState: TState;
68```
69​
70Defined in: [store.ts:33](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L33)
71​
72***
73​
74### state
75​
76```ts
77state: TState;
78```
79​
80Defined in: [store.ts:32](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L32)
81​
82## Methods
83​
84### setState()
85​
86```ts
87setState(updater): void
88```
89​
90Defined in: [store.ts:51](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L51)
91​
92#### Parameters
93​
94##### updater
95​
96`TUpdater`
97​
98#### Returns
99​
100`void`
101​
102***
103​
104### subscribe()
105​
106```ts
107subscribe(listener): () => void
108```
109​
110Defined in: [store.ts:42](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L42)
111​
112#### Parameters
113​
114##### listener
115​
116`Listener`\<`TState`\>
117​
118#### Returns
119​
120`Function`
121​
122##### Returns
123​
124`void`