Skip to content

Commit 768b8b5

Browse files
ci: apply automated fixes and generate docs
1 parent 6dc28fb commit 768b8b5

26 files changed

Lines changed: 375 additions & 63 deletions

docs/reference/classes/ReadonlyStore.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: ReadonlyStore
55

66
# Class: ReadonlyStore\<T\>
77

8-
Defined in: [store.ts:59](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L59)
8+
Defined in: [store.ts:69](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L69)
99

1010
## Type Parameters
1111

@@ -25,7 +25,7 @@ Defined in: [store.ts:59](https://github.com/TanStack/store/blob/main/packages/s
2525
new ReadonlyStore<T>(getValue): ReadonlyStore<T>;
2626
```
2727

28-
Defined in: [store.ts:64](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L64)
28+
Defined in: [store.ts:74](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L74)
2929

3030
#### Parameters
3131

@@ -43,7 +43,7 @@ Defined in: [store.ts:64](https://github.com/TanStack/store/blob/main/packages/s
4343
new ReadonlyStore<T>(initialValue): ReadonlyStore<T>;
4444
```
4545

46-
Defined in: [store.ts:65](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L65)
46+
Defined in: [store.ts:75](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L75)
4747

4848
#### Parameters
4949

@@ -65,7 +65,7 @@ Defined in: [store.ts:65](https://github.com/TanStack/store/blob/main/packages/s
6565
get state(): T;
6666
```
6767

68-
Defined in: [store.ts:73](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L73)
68+
Defined in: [store.ts:83](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L83)
6969

7070
##### Returns
7171

@@ -85,7 +85,7 @@ Omit.state
8585
get(): T;
8686
```
8787

88-
Defined in: [store.ts:76](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L76)
88+
Defined in: [store.ts:86](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L86)
8989

9090
#### Returns
9191

@@ -105,7 +105,7 @@ Omit.get
105105
subscribe(observerOrFn): Subscription;
106106
```
107107

108-
Defined in: [store.ts:79](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L79)
108+
Defined in: [store.ts:89](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L89)
109109

110110
#### Parameters
111111

@@ -122,3 +122,40 @@ Defined in: [store.ts:79](https://github.com/TanStack/store/blob/main/packages/s
122122
```ts
123123
Omit.subscribe
124124
```
125+
126+
***
127+
128+
### whileWatched()
129+
130+
```ts
131+
whileWatched(effect): () => void;
132+
```
133+
134+
Defined in: [store.ts:100](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L100)
135+
136+
`effect` will be called while the atom is watched. `effect` may return a
137+
cleanup function, which will be called when the atom is unwatched.
138+
139+
Returns a `stop` function which cancels the listener.
140+
141+
#### Parameters
142+
143+
##### effect
144+
145+
[`WatchedEffect`](../type-aliases/WatchedEffect.md)
146+
147+
#### Returns
148+
149+
```ts
150+
(): void;
151+
```
152+
153+
##### Returns
154+
155+
`void`
156+
157+
#### Implementation of
158+
159+
```ts
160+
Omit.whileWatched
161+
```

docs/reference/classes/Store.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Store
55

66
# Class: Store\<T, TActions\>
77

8-
Defined in: [store.ts:15](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L15)
8+
Defined in: [store.ts:16](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L16)
99

1010
## Type Parameters
1111

@@ -25,7 +25,7 @@ Defined in: [store.ts:15](https://github.com/TanStack/store/blob/main/packages/s
2525
new Store<T, TActions>(getValue): Store<T, TActions>;
2626
```
2727

28-
Defined in: [store.ts:18](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L18)
28+
Defined in: [store.ts:19](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L19)
2929

3030
#### Parameters
3131

@@ -43,7 +43,7 @@ Defined in: [store.ts:18](https://github.com/TanStack/store/blob/main/packages/s
4343
new Store<T, TActions>(initialValue): Store<T, TActions>;
4444
```
4545

46-
Defined in: [store.ts:19](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L19)
46+
Defined in: [store.ts:20](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L20)
4747

4848
#### Parameters
4949

@@ -61,7 +61,7 @@ Defined in: [store.ts:19](https://github.com/TanStack/store/blob/main/packages/s
6161
new Store<T, TActions>(initialValue, actionsFactory): Store<T, TActions>;
6262
```
6363

64-
Defined in: [store.ts:20](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L20)
64+
Defined in: [store.ts:21](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L21)
6565

6666
#### Parameters
6767

@@ -85,7 +85,7 @@ Defined in: [store.ts:20](https://github.com/TanStack/store/blob/main/packages/s
8585
readonly actions: TActions;
8686
```
8787

88-
Defined in: [store.ts:17](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L17)
88+
Defined in: [store.ts:18](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L18)
8989

9090
## Accessors
9191

@@ -97,7 +97,7 @@ Defined in: [store.ts:17](https://github.com/TanStack/store/blob/main/packages/s
9797
get state(): T;
9898
```
9999

100-
Defined in: [store.ts:46](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L46)
100+
Defined in: [store.ts:47](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L47)
101101

102102
##### Returns
103103

@@ -111,7 +111,7 @@ Defined in: [store.ts:46](https://github.com/TanStack/store/blob/main/packages/s
111111
get(): T;
112112
```
113113

114-
Defined in: [store.ts:49](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L49)
114+
Defined in: [store.ts:50](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L50)
115115

116116
#### Returns
117117

@@ -125,7 +125,7 @@ Defined in: [store.ts:49](https://github.com/TanStack/store/blob/main/packages/s
125125
setState(updater): void;
126126
```
127127

128-
Defined in: [store.ts:43](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L43)
128+
Defined in: [store.ts:44](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L44)
129129

130130
#### Parameters
131131

@@ -145,7 +145,7 @@ Defined in: [store.ts:43](https://github.com/TanStack/store/blob/main/packages/s
145145
subscribe(observerOrFn): Subscription;
146146
```
147147

148-
Defined in: [store.ts:52](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L52)
148+
Defined in: [store.ts:53](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L53)
149149

150150
#### Parameters
151151

@@ -156,3 +156,34 @@ Defined in: [store.ts:52](https://github.com/TanStack/store/blob/main/packages/s
156156
#### Returns
157157

158158
[`Subscription`](../interfaces/Subscription.md)
159+
160+
***
161+
162+
### whileWatched()
163+
164+
```ts
165+
whileWatched(effect): () => void;
166+
```
167+
168+
Defined in: [store.ts:64](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L64)
169+
170+
`effect` will be called while the atom is watched. `effect` may return a
171+
cleanup function, which will be called when the atom is unwatched.
172+
173+
Returns a `stop` function which cancels the listener.
174+
175+
#### Parameters
176+
177+
##### effect
178+
179+
[`WatchedEffect`](../type-aliases/WatchedEffect.md)
180+
181+
#### Returns
182+
183+
```ts
184+
(): void;
185+
```
186+
187+
##### Returns
188+
189+
`void`

docs/reference/functions/batch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: batch
99
function batch(fn): void;
1010
```
1111

12-
Defined in: [atom.ts:62](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L62)
12+
Defined in: [atom.ts:94](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L94)
1313

1414
## Parameters
1515

docs/reference/functions/createAsyncAtom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: createAsyncAtom
99
function createAsyncAtom<T>(getValue, options?): ReadonlyAtom<AsyncAtomState<T, unknown>>;
1010
```
1111

12-
Defined in: [atom.ts:100](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L100)
12+
Defined in: [atom.ts:132](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L132)
1313

1414
## Type Parameters
1515

docs/reference/functions/createAtom.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title: createAtom
1111
function createAtom<T>(getValue, options?): ReadonlyAtom<T>;
1212
```
1313

14-
Defined in: [atom.ts:138](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L138)
14+
Defined in: [atom.ts:207](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L207)
1515

1616
### Type Parameters
1717

@@ -39,7 +39,7 @@ Defined in: [atom.ts:138](https://github.com/TanStack/store/blob/main/packages/s
3939
function createAtom<T>(initialValue, options?): Atom<T>;
4040
```
4141

42-
Defined in: [atom.ts:142](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L142)
42+
Defined in: [atom.ts:211](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L211)
4343

4444
### Type Parameters
4545

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
id: createExternalStoreAtom
3+
title: createExternalStoreAtom
4+
---
5+
6+
# Function: createExternalStoreAtom()
7+
8+
```ts
9+
function createExternalStoreAtom<T>(
10+
getSnapshot,
11+
subscribe,
12+
options?): ReadonlyAtom<T>;
13+
```
14+
15+
Defined in: [atom.ts:191](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L191)
16+
17+
Like React.useSyncExternalStore: pulls external state into an atom.
18+
This can be used for interoperating with other state management libraries.
19+
20+
```ts
21+
import * as redux from "redux"
22+
23+
const reduxStore = redux.createStore((state: number, action: number) => state + action, 0)
24+
const atom = createExternalStoreAtom(reduxStore.getState, reduxStore.subscribe)
25+
26+
const timesTwo = createAtom(() => atom.get() * 2)
27+
timesTwo.subscribe((value) => {
28+
console.log('timesTwo: ', value)
29+
})
30+
31+
reduxStore.dispatch(1)
32+
// timesTwo: 2
33+
reduxStore.dispatch(1)
34+
// timesTwo: 4
35+
```
36+
37+
## Type Parameters
38+
39+
### T
40+
41+
`T`
42+
43+
## Parameters
44+
45+
### getSnapshot
46+
47+
() => `T`
48+
49+
### subscribe
50+
51+
(`onStoreChange`) => () => `void`
52+
53+
### options?
54+
55+
[`AtomOptions`](../interfaces/AtomOptions.md)\<`T`\>
56+
57+
## Returns
58+
59+
[`ReadonlyAtom`](../interfaces/ReadonlyAtom.md)\<`T`\>

docs/reference/functions/createStore.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title: createStore
1111
function createStore<T>(getValue): ReadonlyStore<T>;
1212
```
1313

14-
Defined in: [store.ts:86](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L86)
14+
Defined in: [store.ts:105](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L105)
1515

1616
### Type Parameters
1717

@@ -35,7 +35,7 @@ Defined in: [store.ts:86](https://github.com/TanStack/store/blob/main/packages/s
3535
function createStore<T>(initialValue): Store<T>;
3636
```
3737

38-
Defined in: [store.ts:89](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L89)
38+
Defined in: [store.ts:108](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L108)
3939

4040
### Type Parameters
4141

@@ -59,7 +59,7 @@ Defined in: [store.ts:89](https://github.com/TanStack/store/blob/main/packages/s
5959
function createStore<T, TActions>(initialValue, actions): Store<T, TActions>;
6060
```
6161

62-
Defined in: [store.ts:90](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L90)
62+
Defined in: [store.ts:109](https://github.com/TanStack/store/blob/main/packages/store/src/store.ts#L109)
6363

6464
### Type Parameters
6565

docs/reference/functions/flush.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: flush
99
function flush(): void;
1010
```
1111

12-
Defined in: [atom.ts:81](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L81)
12+
Defined in: [atom.ts:113](https://github.com/TanStack/store/blob/main/packages/store/src/atom.ts#L113)
1313

1414
## Returns
1515

docs/reference/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ title: "@tanstack/store"
3131
- [StoreAction](type-aliases/StoreAction.md)
3232
- [StoreActionMap](type-aliases/StoreActionMap.md)
3333
- [StoreActionsFactory](type-aliases/StoreActionsFactory.md)
34+
- [WatchedEffect](type-aliases/WatchedEffect.md)
3435

3536
## Functions
3637

3738
- [batch](functions/batch.md)
3839
- [createAsyncAtom](functions/createAsyncAtom.md)
3940
- [createAtom](functions/createAtom.md)
41+
- [createExternalStoreAtom](functions/createExternalStoreAtom.md)
4042
- [createStore](functions/createStore.md)
4143
- [flush](functions/flush.md)
4244
- [shallow](functions/shallow.md)

0 commit comments

Comments
 (0)