@effect/atom-react 4.0.0-beta.70 → 4.0.0-beta.71

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.
package/dist/Hooks.d.ts CHANGED
@@ -5,10 +5,15 @@ import type * as AtomRef from "effect/unstable/reactivity/AtomRef";
5
5
  /**
6
6
  * Seeds initial atom values in the current React atom registry.
7
7
  *
8
- * **Details**
8
+ * **When to use**
9
+ *
10
+ * Use to seed atom values from a React component after the current registry
11
+ * already exists.
12
+ *
13
+ * **Gotchas**
9
14
  *
10
- * Each atom is initialized at most once for a given registry, so subsequent
11
- * renders do not overwrite values that have already been established.
15
+ * Each atom is initialized at most once for a given registry by this hook, so
16
+ * later calls for the same atom in that registry are ignored.
12
17
  *
13
18
  * @category hooks
14
19
  * @since 4.0.0
@@ -18,6 +23,19 @@ export declare const useAtomInitialValues: (initialValues: Iterable<readonly [At
18
23
  * Subscribes to an atom in the current React registry and returns its current
19
24
  * value, optionally mapped through a selector.
20
25
  *
26
+ * **When to use**
27
+ *
28
+ * Use when a React component needs to render from an atom value without also
29
+ * returning a setter.
30
+ *
31
+ * **Details**
32
+ *
33
+ * When a selector is provided, the hook maps the atom before subscribing so the
34
+ * component reads the selected value from the current `RegistryContext`.
35
+ *
36
+ * @see {@link useAtom} for reading and updating a writable atom from one component
37
+ * @see {@link useAtomRef} for reading an `AtomRef` directly
38
+ *
21
39
  * @category hooks
22
40
  * @since 4.0.0
23
41
  */
@@ -26,6 +44,19 @@ export declare const useAtomValue: {
26
44
  * Subscribes to an atom in the current React registry and returns its current
27
45
  * value, optionally mapped through a selector.
28
46
  *
47
+ * **When to use**
48
+ *
49
+ * Use when a React component needs to render from an atom value without also
50
+ * returning a setter.
51
+ *
52
+ * **Details**
53
+ *
54
+ * When a selector is provided, the hook maps the atom before subscribing so the
55
+ * component reads the selected value from the current `RegistryContext`.
56
+ *
57
+ * @see {@link useAtom} for reading and updating a writable atom from one component
58
+ * @see {@link useAtomRef} for reading an `AtomRef` directly
59
+ *
29
60
  * @category hooks
30
61
  * @since 4.0.0
31
62
  */
@@ -34,6 +65,19 @@ export declare const useAtomValue: {
34
65
  * Subscribes to an atom in the current React registry and returns its current
35
66
  * value, optionally mapped through a selector.
36
67
  *
68
+ * **When to use**
69
+ *
70
+ * Use when a React component needs to render from an atom value without also
71
+ * returning a setter.
72
+ *
73
+ * **Details**
74
+ *
75
+ * When a selector is provided, the hook maps the atom before subscribing so the
76
+ * component reads the selected value from the current `RegistryContext`.
77
+ *
78
+ * @see {@link useAtom} for reading and updating a writable atom from one component
79
+ * @see {@link useAtomRef} for reading an `AtomRef` directly
80
+ *
37
81
  * @category hooks
38
82
  * @since 4.0.0
39
83
  */
@@ -43,6 +87,20 @@ export declare const useAtomValue: {
43
87
  * Mounts an atom in the current React registry for the lifetime of the
44
88
  * component.
45
89
  *
90
+ * **When to use**
91
+ *
92
+ * Use to keep an atom mounted from a React component without reading, writing,
93
+ * or refreshing it.
94
+ *
95
+ * **Details**
96
+ *
97
+ * The hook uses the current `RegistryContext` and releases the mount through
98
+ * React effect cleanup when the component unmounts or when the registry or atom
99
+ * dependency changes.
100
+ *
101
+ * @see {@link useAtomSet} for mounting a writable atom while returning a setter
102
+ * @see {@link useAtomRefresh} for mounting an atom while returning a refresh callback
103
+ *
46
104
  * @category hooks
47
105
  * @since 4.0.0
48
106
  */
@@ -50,6 +108,19 @@ export declare const useAtomMount: <A>(atom: Atom.Atom<A>) => void;
50
108
  /**
51
109
  * Mounts a writable atom and returns a setter without subscribing to its value.
52
110
  *
111
+ * **When to use**
112
+ *
113
+ * Use when a React component needs to update a writable atom without rendering
114
+ * from that atom's value.
115
+ *
116
+ * **Details**
117
+ *
118
+ * The hook mounts the atom and returns a setter. In value mode the setter
119
+ * accepts a write value or updater function; for `AsyncResult` atoms, `promise`
120
+ * and `promiseExit` modes return a promise for the success value or full `Exit`.
121
+ *
122
+ * @see {@link useAtom} for reading and updating the same writable atom
123
+ *
53
124
  * @category hooks
54
125
  * @since 4.0.0
55
126
  */
@@ -60,6 +131,18 @@ export declare const useAtomSet: <R, W, Mode extends "value" | "promise" | "prom
60
131
  * Mounts an atom and returns a callback that refreshes it in the current React
61
132
  * registry.
62
133
  *
134
+ * **When to use**
135
+ *
136
+ * Use to expose a React callback that requests a refresh for an atom without
137
+ * reading or writing its value.
138
+ *
139
+ * **Details**
140
+ *
141
+ * The hook uses the current `RegistryContext`, mounts the atom for the
142
+ * component lifetime, and returns a callback that calls `registry.refresh`.
143
+ *
144
+ * @see {@link useAtomMount} for mounting an atom without returning a refresh callback
145
+ *
63
146
  * @category hooks
64
147
  * @since 4.0.0
65
148
  */
@@ -68,6 +151,14 @@ export declare const useAtomRefresh: <A>(atom: Atom.Atom<A>) => () => void;
68
151
  * Subscribes to a writable atom and returns its current value together with a
69
152
  * setter for updating it.
70
153
  *
154
+ * **When to use**
155
+ *
156
+ * Use when a React component needs both to render the current value of a
157
+ * writable atom and update it from the same component.
158
+ *
159
+ * @see {@link useAtomValue} for subscribing to an atom without a setter
160
+ * @see {@link useAtomSet} for updating a writable atom without subscribing to its value
161
+ *
71
162
  * @category hooks
72
163
  * @since 4.0.0
73
164
  */
@@ -78,6 +169,23 @@ export declare const useAtom: <R, W, const Mode extends "value" | "promise" | "p
78
169
  * Reads an `AsyncResult` atom through React Suspense, suspending while the
79
170
  * result is initial or configured as waiting.
80
171
  *
172
+ * **When to use**
173
+ *
174
+ * Use when a React component should render only after an `AsyncResult` atom has
175
+ * left its initial state, with loading delegated to a Suspense boundary.
176
+ *
177
+ * **Details**
178
+ *
179
+ * `suspendOnWaiting` defaults to `false`. When `includeFailure` is `true`, a
180
+ * failure result is returned instead of being thrown.
181
+ *
182
+ * **Gotchas**
183
+ *
184
+ * Without `includeFailure`, failure results are thrown with
185
+ * `Cause.squash(result.cause)`, so callers need an error boundary for failures.
186
+ *
187
+ * @see {@link useAtomValue} for reading the raw `AsyncResult` value without Suspense
188
+ *
81
189
  * @category hooks
82
190
  * @since 4.0.0
83
191
  */
@@ -89,6 +197,19 @@ export declare const useAtomSuspense: <A, E, const IncludeFailure extends boolea
89
197
  * Subscribes a callback to an atom in the current React registry for the
90
198
  * component lifetime.
91
199
  *
200
+ * **When to use**
201
+ *
202
+ * Use when a React component needs to run a callback for atom changes without
203
+ * reading the atom value during render.
204
+ *
205
+ * **Details**
206
+ *
207
+ * The subscription is installed in a React effect and cleaned up on unmount or
208
+ * dependency change. When `options.immediate` is enabled, the callback receives
209
+ * the current value when the effect subscribes.
210
+ *
211
+ * @see {@link useAtomValue} for reading an atom value during render instead of running a callback
212
+ *
92
213
  * @category hooks
93
214
  * @since 4.0.0
94
215
  */
@@ -98,6 +219,19 @@ export declare const useAtomSubscribe: <A>(atom: Atom.Atom<A>, f: (_: A) => void
98
219
  /**
99
220
  * Subscribes to an atom ref and returns its latest value.
100
221
  *
222
+ * **When to use**
223
+ *
224
+ * Use when a React component should render from an `AtomRef.ReadonlyRef`
225
+ * directly instead of reading an atom through the current registry.
226
+ *
227
+ * **Details**
228
+ *
229
+ * The hook subscribes with `ref.subscribe`, triggers re-renders through React
230
+ * state, and returns the current `ref.value`.
231
+ *
232
+ * @see {@link useAtomValue} for reading an `Atom` from the current registry
233
+ * @see {@link useAtomRefPropValue} for reading a property ref value
234
+ *
101
235
  * @category hooks
102
236
  * @since 4.0.0
103
237
  */
@@ -105,6 +239,19 @@ export declare const useAtomRef: <A>(ref: AtomRef.ReadonlyRef<A>) => A;
105
239
  /**
106
240
  * Returns a memoized atom ref for a property of another atom ref.
107
241
  *
242
+ * **When to use**
243
+ *
244
+ * Use to derive an `AtomRef` for one property of an object-shaped atom ref.
245
+ *
246
+ * **Details**
247
+ *
248
+ * The hook memoizes `ref.prop(prop)` for the `[ref, prop]` dependency pair and
249
+ * returns the property ref so callers can read, set, update, or subscribe to
250
+ * that nested property.
251
+ *
252
+ * @see {@link useAtomRef} for subscribing to an atom ref value
253
+ * @see {@link useAtomRefPropValue} for subscribing directly to a property value
254
+ *
108
255
  * @category hooks
109
256
  * @since 4.0.0
110
257
  */
@@ -113,6 +260,20 @@ export declare const useAtomRefProp: <A, K extends keyof A>(ref: AtomRef.AtomRef
113
260
  * Subscribes to a property ref derived from an atom ref and returns its current
114
261
  * value.
115
262
  *
263
+ * **When to use**
264
+ *
265
+ * Use when a React component needs only the current value of one property from
266
+ * an object-shaped `AtomRef`.
267
+ *
268
+ * **Details**
269
+ *
270
+ * The hook composes `useAtomRefProp(ref, prop)` with `useAtomRef`, so the
271
+ * property ref is memoized for the `[ref, prop]` pair and then subscribed
272
+ * through `ref.subscribe`.
273
+ *
274
+ * @see {@link useAtomRefProp} for returning the property ref directly
275
+ * @see {@link useAtomRef} for subscribing to a whole atom ref value
276
+ *
116
277
  * @category hooks
117
278
  * @since 4.0.0
118
279
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Hooks.d.ts","sourceRoot":"","sources":["../src/Hooks.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,KAAK,WAAW,MAAM,wCAAwC,CAAA;AAC1E,OAAO,KAAK,IAAI,MAAM,iCAAiC,CAAA;AACvD,OAAO,KAAK,KAAK,OAAO,MAAM,oCAAoC,CAAA;AA8ClE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,eAAe,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,KAAG,IAa9F,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE;IACzB;;;;;;OAMG;IACH,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAC1B;;;;;;OAMG;IACH,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE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AElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAG,CAAC,CAAC,CAAC,CACzD,CAAA"}
package/dist/Hooks.js CHANGED
@@ -61,10 +61,15 @@ const initialValuesSet = /*#__PURE__*/new WeakMap();
61
61
  /**
62
62
  * Seeds initial atom values in the current React atom registry.
63
63
  *
64
- * **Details**
64
+ * **When to use**
65
+ *
66
+ * Use to seed atom values from a React component after the current registry
67
+ * already exists.
68
+ *
69
+ * **Gotchas**
65
70
  *
66
- * Each atom is initialized at most once for a given registry, so subsequent
67
- * renders do not overwrite values that have already been established.
71
+ * Each atom is initialized at most once for a given registry by this hook, so
72
+ * later calls for the same atom in that registry are ignored.
68
73
  *
69
74
  * @category hooks
70
75
  * @since 4.0.0
@@ -87,6 +92,19 @@ export const useAtomInitialValues = initialValues => {
87
92
  * Subscribes to an atom in the current React registry and returns its current
88
93
  * value, optionally mapped through a selector.
89
94
  *
95
+ * **When to use**
96
+ *
97
+ * Use when a React component needs to render from an atom value without also
98
+ * returning a setter.
99
+ *
100
+ * **Details**
101
+ *
102
+ * When a selector is provided, the hook maps the atom before subscribing so the
103
+ * component reads the selected value from the current `RegistryContext`.
104
+ *
105
+ * @see {@link useAtom} for reading and updating a writable atom from one component
106
+ * @see {@link useAtomRef} for reading an `AtomRef` directly
107
+ *
90
108
  * @category hooks
91
109
  * @since 4.0.0
92
110
  */
@@ -123,6 +141,20 @@ const flattenExit = exit => {
123
141
  * Mounts an atom in the current React registry for the lifetime of the
124
142
  * component.
125
143
  *
144
+ * **When to use**
145
+ *
146
+ * Use to keep an atom mounted from a React component without reading, writing,
147
+ * or refreshing it.
148
+ *
149
+ * **Details**
150
+ *
151
+ * The hook uses the current `RegistryContext` and releases the mount through
152
+ * React effect cleanup when the component unmounts or when the registry or atom
153
+ * dependency changes.
154
+ *
155
+ * @see {@link useAtomSet} for mounting a writable atom while returning a setter
156
+ * @see {@link useAtomRefresh} for mounting an atom while returning a refresh callback
157
+ *
126
158
  * @category hooks
127
159
  * @since 4.0.0
128
160
  */
@@ -133,6 +165,19 @@ export const useAtomMount = atom => {
133
165
  /**
134
166
  * Mounts a writable atom and returns a setter without subscribing to its value.
135
167
  *
168
+ * **When to use**
169
+ *
170
+ * Use when a React component needs to update a writable atom without rendering
171
+ * from that atom's value.
172
+ *
173
+ * **Details**
174
+ *
175
+ * The hook mounts the atom and returns a setter. In value mode the setter
176
+ * accepts a write value or updater function; for `AsyncResult` atoms, `promise`
177
+ * and `promiseExit` modes return a promise for the success value or full `Exit`.
178
+ *
179
+ * @see {@link useAtom} for reading and updating the same writable atom
180
+ *
136
181
  * @category hooks
137
182
  * @since 4.0.0
138
183
  */
@@ -145,6 +190,18 @@ export const useAtomSet = (atom, options) => {
145
190
  * Mounts an atom and returns a callback that refreshes it in the current React
146
191
  * registry.
147
192
  *
193
+ * **When to use**
194
+ *
195
+ * Use to expose a React callback that requests a refresh for an atom without
196
+ * reading or writing its value.
197
+ *
198
+ * **Details**
199
+ *
200
+ * The hook uses the current `RegistryContext`, mounts the atom for the
201
+ * component lifetime, and returns a callback that calls `registry.refresh`.
202
+ *
203
+ * @see {@link useAtomMount} for mounting an atom without returning a refresh callback
204
+ *
148
205
  * @category hooks
149
206
  * @since 4.0.0
150
207
  */
@@ -159,6 +216,14 @@ export const useAtomRefresh = atom => {
159
216
  * Subscribes to a writable atom and returns its current value together with a
160
217
  * setter for updating it.
161
218
  *
219
+ * **When to use**
220
+ *
221
+ * Use when a React component needs both to render the current value of a
222
+ * writable atom and update it from the same component.
223
+ *
224
+ * @see {@link useAtomValue} for subscribing to an atom without a setter
225
+ * @see {@link useAtomSet} for updating a writable atom without subscribing to its value
226
+ *
162
227
  * @category hooks
163
228
  * @since 4.0.0
164
229
  */
@@ -200,6 +265,23 @@ function atomResultOrSuspend(registry, atom, suspendOnWaiting) {
200
265
  * Reads an `AsyncResult` atom through React Suspense, suspending while the
201
266
  * result is initial or configured as waiting.
202
267
  *
268
+ * **When to use**
269
+ *
270
+ * Use when a React component should render only after an `AsyncResult` atom has
271
+ * left its initial state, with loading delegated to a Suspense boundary.
272
+ *
273
+ * **Details**
274
+ *
275
+ * `suspendOnWaiting` defaults to `false`. When `includeFailure` is `true`, a
276
+ * failure result is returned instead of being thrown.
277
+ *
278
+ * **Gotchas**
279
+ *
280
+ * Without `includeFailure`, failure results are thrown with
281
+ * `Cause.squash(result.cause)`, so callers need an error boundary for failures.
282
+ *
283
+ * @see {@link useAtomValue} for reading the raw `AsyncResult` value without Suspense
284
+ *
203
285
  * @category hooks
204
286
  * @since 4.0.0
205
287
  */
@@ -215,6 +297,19 @@ export const useAtomSuspense = (atom, options) => {
215
297
  * Subscribes a callback to an atom in the current React registry for the
216
298
  * component lifetime.
217
299
  *
300
+ * **When to use**
301
+ *
302
+ * Use when a React component needs to run a callback for atom changes without
303
+ * reading the atom value during render.
304
+ *
305
+ * **Details**
306
+ *
307
+ * The subscription is installed in a React effect and cleaned up on unmount or
308
+ * dependency change. When `options.immediate` is enabled, the callback receives
309
+ * the current value when the effect subscribes.
310
+ *
311
+ * @see {@link useAtomValue} for reading an atom value during render instead of running a callback
312
+ *
218
313
  * @category hooks
219
314
  * @since 4.0.0
220
315
  */
@@ -225,6 +320,19 @@ export const useAtomSubscribe = (atom, f, options) => {
225
320
  /**
226
321
  * Subscribes to an atom ref and returns its latest value.
227
322
  *
323
+ * **When to use**
324
+ *
325
+ * Use when a React component should render from an `AtomRef.ReadonlyRef`
326
+ * directly instead of reading an atom through the current registry.
327
+ *
328
+ * **Details**
329
+ *
330
+ * The hook subscribes with `ref.subscribe`, triggers re-renders through React
331
+ * state, and returns the current `ref.value`.
332
+ *
333
+ * @see {@link useAtomValue} for reading an `Atom` from the current registry
334
+ * @see {@link useAtomRefPropValue} for reading a property ref value
335
+ *
228
336
  * @category hooks
229
337
  * @since 4.0.0
230
338
  */
@@ -236,6 +344,19 @@ export const useAtomRef = ref => {
236
344
  /**
237
345
  * Returns a memoized atom ref for a property of another atom ref.
238
346
  *
347
+ * **When to use**
348
+ *
349
+ * Use to derive an `AtomRef` for one property of an object-shaped atom ref.
350
+ *
351
+ * **Details**
352
+ *
353
+ * The hook memoizes `ref.prop(prop)` for the `[ref, prop]` dependency pair and
354
+ * returns the property ref so callers can read, set, update, or subscribe to
355
+ * that nested property.
356
+ *
357
+ * @see {@link useAtomRef} for subscribing to an atom ref value
358
+ * @see {@link useAtomRefPropValue} for subscribing directly to a property value
359
+ *
239
360
  * @category hooks
240
361
  * @since 4.0.0
241
362
  */
@@ -244,6 +365,20 @@ export const useAtomRefProp = (ref, prop) => React.useMemo(() => ref.prop(prop),
244
365
  * Subscribes to a property ref derived from an atom ref and returns its current
245
366
  * value.
246
367
  *
368
+ * **When to use**
369
+ *
370
+ * Use when a React component needs only the current value of one property from
371
+ * an object-shaped `AtomRef`.
372
+ *
373
+ * **Details**
374
+ *
375
+ * The hook composes `useAtomRefProp(ref, prop)` with `useAtomRef`, so the
376
+ * property ref is memoized for the `[ref, prop]` pair and then subscribed
377
+ * through `ref.subscribe`.
378
+ *
379
+ * @see {@link useAtomRefProp} for returning the property ref directly
380
+ * @see {@link useAtomRef} for subscribing to a whole atom ref value
381
+ *
247
382
  * @category hooks
248
383
  * @since 4.0.0
249
384
  */
package/dist/Hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Hooks.js","names":["Cause","Effect","Exit","Atom","AtomRegistry","React","RegistryContext","storeRegistry","WeakMap","makeStore","registry","atom","stores","get","undefined","set","store","newStore","subscribe","f","snapshot","getServerSnapshot","getServerValue","useStore","useSyncExternalStore","initialValuesSet","useAtomInitialValues","initialValues","useContext","WeakSet","value","has","add","ensureNode","setValue","useAtomValue","atomB","useMemo","map","mountAtom","useEffect","mount","setAtom","options","mode","useCallback","promise","runPromiseExit","getResult","suspendOnWaiting","then","flattenExit","exit","isSuccess","squash","cause","useAtomMount","useAtomSet","useAtomRefresh","refresh","useAtom","atomPromiseMap","Map","default","atomToPromise","Promise","resolve","dispose","result","_tag","waiting","setTimeout","delete","atomResultOrSuspend","useAtomSuspense","includeFailure","useAtomSubscribe","immediate","useAtomRef","ref","useState","useAtomRefProp","prop","useAtomRefPropValue"],"sources":["../src/Hooks.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;AAqBA,YAAY;;AAEZ,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AAEnC,OAAO,KAAKC,IAAI,MAAM,iCAAiC;AAEvD,OAAO,KAAKC,YAAY,MAAM,yCAAyC;AACvE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,eAAe,QAAQ,sBAAsB;AAQtD,MAAMC,aAAa,gBAAG,IAAIC,OAAO,EAAsE;AAEvG,SAASC,SAASA,CAAIC,QAAmC,EAAEC,IAAkB;EAC3E,IAAIC,MAAM,GAAGL,aAAa,CAACM,GAAG,CAACH,QAAQ,CAAC;EACxC,IAAIE,MAAM,KAAKE,SAAS,EAAE;IACxBF,MAAM,GAAG,IAAIJ,OAAO,EAAE;IACtBD,aAAa,CAACQ,GAAG,CAACL,QAAQ,EAAEE,MAAM,CAAC;EACrC;EACA,MAAMI,KAAK,GAAGJ,MAAM,CAACC,GAAG,CAACF,IAAI,CAAC;EAC9B,IAAIK,KAAK,KAAKF,SAAS,EAAE;IACvB,OAAOE,KAAK;EACd;EACA,MAAMC,QAAQ,GAAiB;IAC7BC,SAASA,CAACC,CAAC;MACT,OAAOT,QAAQ,CAACQ,SAAS,CAACP,IAAI,EAAEQ,CAAC,CAAC;IACpC,CAAC;IACDC,QAAQA,CAAA;MACN,OAAOV,QAAQ,CAACG,GAAG,CAACF,IAAI,CAAC;IAC3B,CAAC;IACDU,iBAAi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S,CAACgB,QAAQ,CAAC,EAAE,CAAC6C,GAAG,CAAC,CAAC;EACrD,OAAOA,GAAG,CAACjD,KAAK;AAClB,CAAC;AAED;;;;;;AAMA,OAAO,MAAMmD,cAAc,GAAGA,CAAuBF,GAAuB,EAAEG,IAAO,KACnF7E,KAAK,CAACgC,OAAO,CAAC,MAAM0C,GAAG,CAACG,IAAI,CAACA,IAAI,CAAC,EAAE,CAACH,GAAG,EAAEG,IAAI,CAAC,CAAC;AAElD;;;;;;;AAOA,OAAO,MAAMC,mBAAmB,GAAGA,CAAuBJ,GAAuB,EAAEG,IAAO,KACxFJ,UAAU,CAACG,cAAc,CAACF,GAAG,EAAEG,IAAI,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Hooks.js","names":["Cause","Effect","Exit","Atom","AtomRegistry","React","RegistryContext","storeRegistry","WeakMap","makeStore","registry","atom","stores","get","undefined","set","store","newStore","subscribe","f","snapshot","getServerSnapshot","getServerValue","useStore","useSyncExternalStore","initialValuesSet","useAtomInitialValues","initialValues","useContext","WeakSet","value","has","add","ensureNode","setValue","useAtomValue","atomB","useMemo","map","mountAtom","useEffect","mount","setAtom","options","mode","useCallback","promise","runPromiseExit","getResult","suspendOnWaiting","then","flattenExit","exit","isSuccess","squash","cause","useAtomMount","useAtomSet","useAtomRefresh","refresh","useAtom","atomPromiseMap","Map","default","atomToPromise","Promise","resolve","dispose","result","_tag","waiting","setTimeout","delete","atomResultOrSuspend","useAtomSuspense","includeFailure","useAtomSubscribe","immediate","useAtomRef","ref","useState","useAtomRefProp","prop","useAtomRefPropValue"],"sources":["../src/Hooks.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;AAqBA,YAAY;;AAEZ,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AAEnC,OAAO,KAAKC,IAAI,MAAM,iCAAiC;AAEvD,OA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;;;;;;AAqBA,OAAO,MAAMC,mBAAmB,GAAGA,CAAuBJ,GAAuB,EAAEG,IAAO,KACxFJ,UAAU,CAACG,cAAc,CAACF,GAAG,EAAEG,IAAI,CAAC,CAAC","ignoreList":[]}
@@ -15,12 +15,20 @@ export interface HydrationBoundaryProps {
15
15
  * Hydrates dehydrated Atom values into the current Atom registry for a React
16
16
  * subtree.
17
17
  *
18
+ * **When to use**
19
+ *
20
+ * Use to apply dehydrated Atom state to a React subtree that reads from the
21
+ * nearest `RegistryContext`.
22
+ *
18
23
  * **Details**
19
24
  *
20
25
  * New Atom values are hydrated during render so descendants can read them
21
26
  * immediately, while values for existing Atoms are deferred until after commit
22
27
  * so transition data does not update the current UI before React accepts it.
23
28
  *
29
+ * @see {@link Hydration.dehydrate} for producing dehydrated Atom state
30
+ * @see {@link Hydration.hydrate} for lower-level non-React hydration
31
+ *
24
32
  * @category components
25
33
  * @since 4.0.0
26
34
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ReactHydration.d.ts","sourceRoot":"","sources":["../src/ReactHydration.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,SAAS,MAAM,sCAAsC,CAAA;AACjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IAC1C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA6D9D,CAAA"}
1
+ {"version":3,"file":"ReactHydration.d.ts","sourceRoot":"","sources":["../src/ReactHydration.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,SAAS,MAAM,sCAAsC,CAAA;AACjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IAC1C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA6D9D,CAAA"}
@@ -31,12 +31,20 @@ import { RegistryContext } from "./RegistryContext.js";
31
31
  * Hydrates dehydrated Atom values into the current Atom registry for a React
32
32
  * subtree.
33
33
  *
34
+ * **When to use**
35
+ *
36
+ * Use to apply dehydrated Atom state to a React subtree that reads from the
37
+ * nearest `RegistryContext`.
38
+ *
34
39
  * **Details**
35
40
  *
36
41
  * New Atom values are hydrated during render so descendants can read them
37
42
  * immediately, while values for existing Atoms are deferred until after commit
38
43
  * so transition data does not update the current UI before React accepts it.
39
44
  *
45
+ * @see {@link Hydration.dehydrate} for producing dehydrated Atom state
46
+ * @see {@link Hydration.hydrate} for lower-level non-React hydration
47
+ *
40
48
  * @category components
41
49
  * @since 4.0.0
42
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ReactHydration.js","names":["Hydration","React","RegistryContext","HydrationBoundary","children","state","registry","useContext","hydrationQueue","useMemo","dehydratedAtoms","Array","from","nodes","getNodes","newDehydratedAtoms","existingDehydratedAtoms","dehydratedAtom","existingNode","get","key","push","length","hydrate","undefined","useEffect","createElement","Fragment"],"sources":["../src/ReactHydration.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,YAAY;;AACZ,OAAO,KAAKA,SAAS,MAAM,sCAAsC;AACjE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,eAAe,QAAQ,sBAAsB;AActD;;;;;;;;;;;;;AAaA,OAAO,MAAMC,iBAAiB,GAAqCA,CAAC;EAClEC,QAAQ;EACRC;AAAK,CACN,KAAI;EACH,MAAMC,QAAQ,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vB,QAAQ,CAAC;AAC1D,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ReactHydration.js","names":["Hydration","React","RegistryContext","HydrationBoundary","children","state","registry","useContext","hydrationQueue","useMemo","dehydratedAtoms","Array","from","nodes","getNodes","newDehydratedAtoms","existingDehydratedAtoms","dehydratedAtom","existingNode","get","key","push","length","hydrate","undefined","useEffect","createElement","Fragment"],"sources":["../src/ReactHydration.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,YAAY;;AACZ,OAAO,KAAKA,SAAS,MAAM,sCAAsC;AACjE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,eAAe,QAAQ,sBAAsB;AActD;;;;;;;;;;;;;;;;;;;;;AAqBA,OAAO,MAAMC,iBAAiB,GAAqCA,CAAC;EAClEC,QAAQ;EACRC;AAAK,CACN,KAAI;EACH,MAAMC,QAAQ,GAAGL,KAAK,CAACM,UAAU,CAACL,eAAe,CAAC;EAElD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMM,cAAc,GAAqDP,KAAK,CAACQ,OAAO,CAAC,MAAK;IAC1F,IAAIJ,KAAK,EAAE;MACT,MAAMK,eAAe,GAAGC,KAAK,CAACC,IAAI,CAACP,KAAK,CAAyC;MACjF,MAAMQ,KAAK,GAAGP,QAAQ,CAACQ,QAAQ,EAAE;MAEjC,MAAMC,kBAAkB,GAAyC,EAAE;MACnE,MAAMC,uBAAuB,GAAyC,EAAE;MAExE,KAAK,MAAMC,cAAc,IAAIP,eAAe,EAAE;QAC5C,MAAMQ,YAAY,GAAGL,KAAK,CAACM,GAAG,CAACF,cAAc,CAACG,GAAG,CAAC;QAElD,IAAI,CAACF,YAAY,EAAE;UACjB;UACAH,kBAAkB,CAACM,IAAI,CAACJ,cAAc,CAAC;QACzC,CAAC,MAAM;UACL;UACAD,uBAAuB,CAACK,IAAI,CAACJ,cAAc,CAAC;QAC9C;MACF;MAEA,IAAIF,kBAAkB,CAACO,MAAM,GAAG,CAAC,EAAE;QACjC;QACA;QACAtB,SAAS,CAACuB,OAAO,CAACjB,QAAQ,EAAES,kBAAkB,CAAC;MACjD;MAEA,IAAIC,uBAAuB,CAACM,MAAM,GAAG,CAAC,EAAE;QACtC,OAAON,uBAAuB;MAChC;IACF;IACA,OAAOQ,SAAS;EAClB,CAAC,EAAE,CAAClB,QAAQ,EAAED,KAAK,CAAC,CAAC;EAErBJ,KAAK,CAACwB,SAAS,CAAC,MAAK;IACnB,IAAIjB,cAAc,EAAE;MAClBR,SAAS,CAACuB,OAAO,CAACjB,QAAQ,EAAEE,cAAc,CAAC;IAC7C;EACF,CAAC,EAAE,CAACF,QAAQ,EAAEE,cAAc,CAAC,CAAC;EAE9B,OAAOP,KAAK,CAACyB,aAAa,CAACzB,KAAK,CAAC0B,QAAQ,EAAE,EAAE,EAAEvB,QAAQ,CAAC;AAC1D,CAAC","ignoreList":[]}
@@ -14,6 +14,14 @@ export declare function scheduleTask(f: () => void): () => void;
14
14
  * hydration helpers, defaulting to a standalone registry when no provider is
15
15
  * present.
16
16
  *
17
+ * **When to use**
18
+ *
19
+ * Use to supply an existing `AtomRegistry` through React context when hooks or
20
+ * hydration helpers need to share registry state that is managed outside
21
+ * `RegistryProvider`.
22
+ *
23
+ * @see {@link RegistryProvider} for creating and providing a registry for a React subtree
24
+ *
17
25
  * @category context
18
26
  * @since 4.0.0
19
27
  */
@@ -22,6 +30,25 @@ export declare const RegistryContext: React.Context<AtomRegistry.AtomRegistry>;
22
30
  * Provides a stable `AtomRegistry` to a React subtree, optionally seeding
23
31
  * initial atom values and overriding registry scheduling or idle settings.
24
32
  *
33
+ * **When to use**
34
+ *
35
+ * Use to scope atom state, scheduling, and idle cleanup to a React subtree.
36
+ *
37
+ * **Details**
38
+ *
39
+ * The provider creates one `AtomRegistry` with `AtomRegistry.make`, passes it
40
+ * through `RegistryContext.Provider`, and forwards `initialValues`,
41
+ * `scheduleTask`, `timeoutResolution`, and `defaultIdleTTL` only when that
42
+ * registry is created.
43
+ *
44
+ * **Gotchas**
45
+ *
46
+ * Option changes after the first render do not rebuild the registry. When the
47
+ * provider unmounts, registry disposal is delayed briefly and canceled if the
48
+ * provider remounts before the timeout fires.
49
+ *
50
+ * @see {@link RegistryContext} for the React context supplied by this provider
51
+ *
25
52
  * @category context
26
53
  * @since 4.0.0
27
54
  */
@@ -1 +1 @@
1
- {"version":3,"file":"RegistryContext.d.ts","sourceRoot":"","sources":["../src/RegistryContext.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,KAAK,IAAI,MAAM,iCAAiC,CAAA;AAC5D,OAAO,KAAK,YAAY,MAAM,yCAAyC,CAAA;AACvE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAGtD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,0CAGzB,CAAA;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAA;IAC/C,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAA;IAC7E,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC,GAAG,SAAS,CAAA;IACnE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7C,mFA2BA,CAAA"}
1
+ {"version":3,"file":"RegistryContext.d.ts","sourceRoot":"","sources":["../src/RegistryContext.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,KAAK,IAAI,MAAM,iCAAiC,CAAA;AAC5D,OAAO,KAAK,YAAY,MAAM,yCAAyC,CAAA;AACvE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAGtD;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,0CAGzB,CAAA;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAA;IAC/C,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAA;IAC7E,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC,GAAG,SAAS,CAAA;IACnE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7C,mFA2BA,CAAA"}
@@ -44,6 +44,14 @@ export function scheduleTask(f) {
44
44
  * hydration helpers, defaulting to a standalone registry when no provider is
45
45
  * present.
46
46
  *
47
+ * **When to use**
48
+ *
49
+ * Use to supply an existing `AtomRegistry` through React context when hooks or
50
+ * hydration helpers need to share registry state that is managed outside
51
+ * `RegistryProvider`.
52
+ *
53
+ * @see {@link RegistryProvider} for creating and providing a registry for a React subtree
54
+ *
47
55
  * @category context
48
56
  * @since 4.0.0
49
57
  */
@@ -55,6 +63,25 @@ export const RegistryContext = /*#__PURE__*/React.createContext(/*#__PURE__*/Ato
55
63
  * Provides a stable `AtomRegistry` to a React subtree, optionally seeding
56
64
  * initial atom values and overriding registry scheduling or idle settings.
57
65
  *
66
+ * **When to use**
67
+ *
68
+ * Use to scope atom state, scheduling, and idle cleanup to a React subtree.
69
+ *
70
+ * **Details**
71
+ *
72
+ * The provider creates one `AtomRegistry` with `AtomRegistry.make`, passes it
73
+ * through `RegistryContext.Provider`, and forwards `initialValues`,
74
+ * `scheduleTask`, `timeoutResolution`, and `defaultIdleTTL` only when that
75
+ * registry is created.
76
+ *
77
+ * **Gotchas**
78
+ *
79
+ * Option changes after the first render do not rebuild the registry. When the
80
+ * provider unmounts, registry disposal is delayed briefly and canceled if the
81
+ * provider remounts before the timeout fires.
82
+ *
83
+ * @see {@link RegistryContext} for the React context supplied by this provider
84
+ *
58
85
  * @category context
59
86
  * @since 4.0.0
60
87
  */
@@ -1 +1 @@
1
- {"version":3,"file":"RegistryContext.js","names":["AtomRegistry","React","Scheduler","scheduleTask","f","node","unstable_scheduleCallback","unstable_LowPriority","unstable_cancelCallback","RegistryContext","createContext","make","defaultIdleTTL","RegistryProvider","options","ref","useRef","current","registry","initialValues","timeoutResolution","useEffect","timeout","undefined","clearTimeout","setTimeout","dispose","createElement","Provider","value","children"],"sources":["../src/RegistryContext.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,YAAY;;AAGZ,OAAO,KAAKA,YAAY,MAAM,yCAAyC;AACvE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAO,KAAKC,SAAS,MAAM,WAAW;AAEtC;;;;;;;AAOA,OAAM,SAAUC,YAAYA,CAACC,CAAa;EACxC,MAAMC,IAAI,GAAGH,SAAS,CAACI,yBAAyB,CAACJ,SAAS,CAACK,oBAAoB,EAAEH,CAAC,CAAC;EACnF,OAAO,MAAMF,SAAS,CAACM,uBAAuB,CAACH,IAAI,CAAC;AACtD;AAEA;;;;;;;;AAQA,OAAO,MAAMI,eAAe,gBAAGR,KAAK,CAACS,aAAa,cAA4BV,YAAY,CAACW,IAAI,CAAC;EAC9FR,YAAY;EACZS,cAAc,EAAE;CACjB,CAAC,CAAC;AAEH;;;;;;;AAOA,OAAO,MAAMC,gBAAgB,GAAIC,OAMhC,IAAI;EACH,MAAMC,GAAG,GAAGd,KAAK,CAACe,MAAM,CAGrB,IAAI,CAAC;EACR,IAAID,GAAG,CAACE,OAAO,KAAK,IAAI,EAAE;IACxBF,GAAG,CAACE,OAAO,GAAG;MACZC,QAAQ,EAAElB,YAAY,CAACW,IAAI,CAAC;QAC1BR,YAAY,EAAEW,OAAO,CAACX,YAAY,IAAIA,YAAY;QAClDgB,aAAa,EAAEL,OAAO,CAACK,aAAa;QACpCC,iBAAiB,EAAEN,OAAO,CAACM,iBAAiB;QAC5CR,cAAc,EAAEE,OAAO,CAACF;OACzB;KACF;EACH;EACAX,KAAK,CAACoB,SAAS,CAAC,MAAK;IACnB,IAAIN,GAAG,CAACE,OAAO,EAAEK,OAAO,KAAKC,SAAS,EAAE;MACtCC,YAAY,CAACT,GAAG,CAACE,OAAO,CAACK,OAAO,CAAC;IACnC;IACA,OAAO,MAAK;MACVP,GAAG,CAACE,OAAQ,CAACK,OAAO,GAAGG,UAAU,CAAC,MAAK;QACrCV,GAAG,CAACE,OAAO,EAAEC,QAAQ,CAACQ,OAAO,EAAE;QAC/BX,GAAG,CAACE,OAAO,GAAG,IAAI;MACpB,CAAC,EAAE,GAAG,CAAQ;IAChB,CAAC;EACH,CAAC,EAAE,CAACF,GAAG,CAAC,CAAC;EACT,OAAOd,KAAK,CAAC0B,aAAa,CAAClB,eAAe,CAACmB,QAAQ,EAAE;IAAEC,KAAK,EAAEd,GAAG,CAACE,OAAO,CAACC;EAAQ,CAAE,EAAEJ,OAAO,EAAEgB,QAAQ,CAAC;AAC1G,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"RegistryContext.js","names":["AtomRegistry","React","Scheduler","scheduleTask","f","node","unstable_scheduleCallback","unstable_LowPriority","unstable_cancelCallback","RegistryContext","createContext","make","defaultIdleTTL","RegistryProvider","options","ref","useRef","current","registry","initialValues","timeoutResolution","useEffect","timeout","undefined","clearTimeout","setTimeout","dispose","createElement","Provider","value","children"],"sources":["../src/RegistryContext.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,YAAY;;AAGZ,OAAO,KAAKA,YAAY,MAAM,yCAAyC;AACvE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAO,KAAKC,SAAS,MAAM,WAAW;AAEtC;;;;;;;AAOA,OAAM,SAAUC,YAAYA,CAACC,CAAa;EACxC,MAAMC,IAAI,GAAGH,SAAS,CAACI,yBAAyB,CAACJ,SAAS,CAACK,oBAAoB,EAAEH,CAAC,CAAC;EACnF,OAAO,MAAMF,SAAS,CAACM,uBAAuB,CAACH,IAAI,CAAC;AACtD;AAEA;;;;;;;;;;;;;;;;AAgBA,OAAO,MAAMI,eAAe,gBAAGR,KAAK,CAACS,aAAa,cAA4BV,YAAY,CAACW,IAAI,CAAC;EAC9FR,YAAY;EACZS,cAAc,EAAE;CACjB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,OAAO,MAAMC,gBAAgB,GAAIC,OAMhC,IAAI;EACH,MAAMC,GAAG,GAAGd,KAAK,CAACe,MAAM,CAGrB,IAAI,CAAC;EACR,IAAID,GAAG,CAACE,OAAO,KAAK,IAAI,EAAE;IACxBF,GAAG,CAACE,OAAO,GAAG;MACZC,QAAQ,EAAElB,YAAY,CAACW,IAAI,CAAC;QAC1BR,YAAY,EAAEW,OAAO,CAACX,YAAY,IAAIA,YAAY;QAClDgB,aAAa,EAAEL,OAAO,CAACK,aAAa;QACpCC,iBAAiB,EAAEN,OAAO,CAACM,iBAAiB;QAC5CR,cAAc,EAAEE,OAAO,CAACF;OACzB;KACF;EACH;EACAX,KAAK,CAACoB,SAAS,CAAC,MAAK;IACnB,IAAIN,GAAG,CAACE,OAAO,EAAEK,OAAO,KAAKC,SAAS,EAAE;MACtCC,YAAY,CAACT,GAAG,CAACE,OAAO,CAACK,OAAO,CAAC;IACnC;IACA,OAAO,MAAK;MACVP,GAAG,CAACE,OAAQ,CAACK,OAAO,GAAGG,UAAU,CAAC,MAAK;QACrCV,GAAG,CAACE,OAAO,EAAEC,QAAQ,CAACQ,OAAO,EAAE;QAC/BX,GAAG,CAACE,OAAO,GAAG,IAAI;MACpB,CAAC,EAAE,GAAG,CAAQ;IAChB,CAAC;EACH,CAAC,EAAE,CAACF,GAAG,CAAC,CAAC;EACT,OAAOd,KAAK,CAAC0B,aAAa,CAAClB,eAAe,CAACmB,QAAQ,EAAE;IAAEC,KAAK,EAAEd,GAAG,CAACE,OAAO,CAACC;EAAQ,CAAE,EAAEJ,OAAO,EAAEgB,QAAQ,CAAC;AAC1G,CAAC","ignoreList":[]}
@@ -1,7 +1,12 @@
1
1
  import type * as Atom from "effect/unstable/reactivity/Atom";
2
2
  import * as React from "react";
3
3
  /**
4
- * Type identifier for ScopedAtom.
4
+ * Literal type used as the `ScopedAtom` type identifier.
5
+ *
6
+ * **Details**
7
+ *
8
+ * Used as the computed property key and marker value stored on `ScopedAtom`
9
+ * objects.
5
10
  *
6
11
  * @category type IDs
7
12
  * @since 4.0.0
@@ -10,6 +15,11 @@ export type TypeId = "~@effect/atom-react/ScopedAtom";
10
15
  /**
11
16
  * Type identifier for ScopedAtom.
12
17
  *
18
+ * **Details**
19
+ *
20
+ * Used as the computed property key and marker value stored on `ScopedAtom`
21
+ * objects.
22
+ *
13
23
  * @category type IDs
14
24
  * @since 4.0.0
15
25
  */
@@ -20,15 +30,15 @@ export declare const TypeId: TypeId;
20
30
  * **Example** (Providing and reading a scoped atom)
21
31
  *
22
32
  * ```ts
23
- * import * as AtomReact from "@effect/atom-react"
33
+ * import { make, useAtomValue } from "@effect/atom-react"
24
34
  * import { Atom } from "effect/unstable/reactivity"
25
35
  * import * as React from "react"
26
36
  *
27
- * const Counter = AtomReact.make(() => Atom.make(0))
37
+ * const Counter = make(() => Atom.make(0))
28
38
  *
29
39
  * function View() {
30
40
  * const atom = Counter.use()
31
- * const value = AtomReact.useAtomValue(atom)
41
+ * const value = useAtomValue(atom)
32
42
  * return React.createElement("div", null, value)
33
43
  * }
34
44
  *
@@ -54,18 +64,34 @@ export interface ScopedAtom<A extends Atom.Atom<any>, Input = never> {
54
64
  /**
55
65
  * Creates a ScopedAtom from a factory function.
56
66
  *
67
+ * **When to use**
68
+ *
69
+ * Use to create an atom instance that is owned by a React provider and scoped
70
+ * to a component subtree.
71
+ *
72
+ * **Details**
73
+ *
74
+ * The returned scoped atom includes a `Provider`, `Context`, and `use`
75
+ * accessor. The provider creates the atom once for its lifetime, passing the
76
+ * `value` prop to the factory when the scoped atom expects input.
77
+ *
78
+ * **Gotchas**
79
+ *
80
+ * `use` must run under the matching provider. Changing the provider `value`
81
+ * prop after mount does not recreate the atom.
82
+ *
57
83
  * **Example** (Creating a scoped atom with input)
58
84
  *
59
85
  * ```ts
60
- * import * as AtomReact from "@effect/atom-react"
86
+ * import { make, useAtomValue } from "@effect/atom-react"
61
87
  * import { Atom } from "effect/unstable/reactivity"
62
88
  * import * as React from "react"
63
89
  *
64
- * const User = AtomReact.make((name: string) => Atom.make(name))
90
+ * const User = make((name: string) => Atom.make(name))
65
91
  *
66
92
  * function UserName() {
67
93
  * const atom = User.use()
68
- * const value = AtomReact.useAtomValue(atom)
94
+ * const value = useAtomValue(atom)
69
95
  * return React.createElement("span", null, value)
70
96
  * }
71
97
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ScopedAtom.d.ts","sourceRoot":"","sources":["../src/ScopedAtom.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,KAAK,IAAI,MAAM,iCAAiC,CAAA;AAC5D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,gCAAgC,CAAA;AAErD;;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;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,EAAE,MAAyC,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK;IACjE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,GAAG,IAAI,CAAC,CAAA;IACR,QAAQ,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAA;KAAE,CAAC,GAC7F,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAA;IACxF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,EAC1D,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,CAAC,KACnC,UAAU,CAAC,CAAC,EAAE,KAAK,CA6BrB,CAAA"}
@@ -24,6 +24,11 @@ import * as React from "react";
24
24
  /**
25
25
  * Type identifier for ScopedAtom.
26
26
  *
27
+ * **Details**
28
+ *
29
+ * Used as the computed property key and marker value stored on `ScopedAtom`
30
+ * objects.
31
+ *
27
32
  * @category type IDs
28
33
  * @since 4.0.0
29
34
  */
@@ -31,18 +36,34 @@ export const TypeId = "~@effect/atom-react/ScopedAtom";
31
36
  /**
32
37
  * Creates a ScopedAtom from a factory function.
33
38
  *
39
+ * **When to use**
40
+ *
41
+ * Use to create an atom instance that is owned by a React provider and scoped
42
+ * to a component subtree.
43
+ *
44
+ * **Details**
45
+ *
46
+ * The returned scoped atom includes a `Provider`, `Context`, and `use`
47
+ * accessor. The provider creates the atom once for its lifetime, passing the
48
+ * `value` prop to the factory when the scoped atom expects input.
49
+ *
50
+ * **Gotchas**
51
+ *
52
+ * `use` must run under the matching provider. Changing the provider `value`
53
+ * prop after mount does not recreate the atom.
54
+ *
34
55
  * **Example** (Creating a scoped atom with input)
35
56
  *
36
57
  * ```ts
37
- * import * as AtomReact from "@effect/atom-react"
58
+ * import { make, useAtomValue } from "@effect/atom-react"
38
59
  * import { Atom } from "effect/unstable/reactivity"
39
60
  * import * as React from "react"
40
61
  *
41
- * const User = AtomReact.make((name: string) => Atom.make(name))
62
+ * const User = make((name: string) => Atom.make(name))
42
63
  *
43
64
  * function UserName() {
44
65
  * const atom = User.use()
45
- * const value = AtomReact.useAtomValue(atom)
66
+ * const value = useAtomValue(atom)
46
67
  * return React.createElement("span", null, value)
47
68
  * }
48
69
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ScopedAtom.js","names":["React","TypeId","make","f","Context","createContext","undefined","use","atom","useContext","Error","Provider","props","useRef","current","value","createElement","children"],"sources":["../src/ScopedAtom.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,YAAY;;AAGZ,OAAO,KAAKA,KAAK,MAAM,OAAO;AAU9B;;;;;;AAMA,OAAO,MAAMC,MAAM,GAAW,gCAAgC;AAoC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,OAAO,MAAMC,IAAI,GACfC,CAAoC,IACZ;EACxB,MAAMC,OAAO,GAAGJ,KAAK,CAACK,aAAa,CAAIC,SAAyB,CAAC;EAEjE,MAAMC,GAAG,GAAGA,CAAA,KAAQ;IAClB,MAAMC,IAAI,GAAGR,KAAK,CAACS,UAAU,CAACL,OAAO,CAAC;IACtC,IAAII,IAAI,KAAKF,SAAS,EAAE;MACtB,MAAM,IAAII,KAAK,CAAC,yCAAyC,CAAC;IAC5D;IACA,OAAOF,IAAI;EACb,CAAC;EAED,MAAMG,QAAQ,GAA2FC,KAAK,IAAI;IAChH,MAAMJ,IAAI,GAAGR,KAAK,CAACa,MAAM,CAAW,IAAI,CAAC;IACzC,IAAIL,IAAI,CAACM,OAAO,KAAK,IAAI,EAAE;MACzB,IAAI,OAAO,IAAIF,KAAK,EAAE;QACpBJ,IAAI,CAACM,OAAO,GAAIX,CAAyB,CAACS,KAAK,CAACG,KAAc,CAAC;MACjE,CAAC,MAAM;QACLP,IAAI,CAACM,OAAO,GAAIX,CAAa,EAAE;MACjC;IACF;IACA,OAAOH,KAAK,CAACgB,aAAa,CAACZ,OAAO,CAACO,QAAQ,EAAE;MAAEI,KAAK,EAAEP,IAAI,CAACM;IAAO,CAAE,EAAEF,KAAK,CAACK,QAAQ,CAAC;EACvF,CAAC;EAED,OAAO;IACL,CAAChB,MAAM,GAAGA,MAAM;IAChBM,GAAG;IACHI,QAAQ,EAAEA,QAAe;IACzBP;GACD;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ScopedAtom.js","names":["React","TypeId","make","f","Context","createContext","undefined","use","atom","useContext","Error","Provider","props","useRef","current","value","createElement","children"],"sources":["../src/ScopedAtom.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,YAAY;;AAGZ,OAAO,KAAKA,KAAK,MAAM,OAAO;AAe9B;;;;;;;;;;;AAWA,OAAO,MAAMC,MAAM,GAAW,gCAAgC;AAoC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,OAAO,MAAMC,IAAI,GACfC,CAAoC,IACZ;EACxB,MAAMC,OAAO,GAAGJ,KAAK,CAACK,aAAa,CAAIC,SAAyB,CAAC;EAEjE,MAAMC,GAAG,GAAGA,CAAA,KAAQ;IAClB,MAAMC,IAAI,GAAGR,KAAK,CAACS,UAAU,CAACL,OAAO,CAAC;IACtC,IAAII,IAAI,KAAKF,SAAS,EAAE;MACtB,MAAM,IAAII,KAAK,CAAC,yCAAyC,CAAC;IAC5D;IACA,OAAOF,IAAI;EACb,CAAC;EAED,MAAMG,QAAQ,GAA2FC,KAAK,IAAI;IAChH,MAAMJ,IAAI,GAAGR,KAAK,CAACa,MAAM,CAAW,IAAI,CAAC;IACzC,IAAIL,IAAI,CAACM,OAAO,KAAK,IAAI,EAAE;MACzB,IAAI,OAAO,IAAIF,KAAK,EAAE;QACpBJ,IAAI,CAACM,OAAO,GAAIX,CAAyB,CAACS,KAAK,CAACG,KAAc,CAAC;MACjE,CAAC,MAAM;QACLP,IAAI,CAACM,OAAO,GAAIX,CAAa,EAAE;MACjC;IACF;IACA,OAAOH,KAAK,CAACgB,aAAa,CAACZ,OAAO,CAACO,QAAQ,EAAE;MAAEI,KAAK,EAAEP,IAAI,CAACM;IAAO,CAAE,EAAEF,KAAK,CAACK,QAAQ,CAAC;EACvF,CAAC;EAED,OAAO;IACL,CAAChB,MAAM,GAAGA,MAAM;IAChBM,GAAG;IACHI,QAAQ,EAAEA,QAAe;IACzBP;GACD;AACH,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/atom-react",
3
- "version": "4.0.0-beta.70",
3
+ "version": "4.0.0-beta.71",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "React bindings for the Effect Atom modules",
@@ -45,7 +45,7 @@
45
45
  "peerDependencies": {
46
46
  "react": "^19.2.4",
47
47
  "scheduler": "*",
48
- "effect": "^4.0.0-beta.70"
48
+ "effect": "^4.0.0-beta.71"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@testing-library/dom": "^10.4.1",
@@ -59,7 +59,7 @@
59
59
  "react-dom": "19.2.6",
60
60
  "react-error-boundary": "^6.1.1",
61
61
  "scheduler": "^0.27.0",
62
- "effect": "^4.0.0-beta.70"
62
+ "effect": "^4.0.0-beta.71"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsc -b tsconfig.json && pnpm babel",
package/src/Hooks.ts CHANGED
@@ -75,10 +75,15 @@ const initialValuesSet = new WeakMap<AtomRegistry.AtomRegistry, WeakSet<Atom.Ato
75
75
  /**
76
76
  * Seeds initial atom values in the current React atom registry.
77
77
  *
78
- * **Details**
78
+ * **When to use**
79
+ *
80
+ * Use to seed atom values from a React component after the current registry
81
+ * already exists.
79
82
  *
80
- * Each atom is initialized at most once for a given registry, so subsequent
81
- * renders do not overwrite values that have already been established.
83
+ * **Gotchas**
84
+ *
85
+ * Each atom is initialized at most once for a given registry by this hook, so
86
+ * later calls for the same atom in that registry are ignored.
82
87
  *
83
88
  * @category hooks
84
89
  * @since 4.0.0
@@ -102,6 +107,19 @@ export const useAtomInitialValues = (initialValues: Iterable<readonly [Atom.Atom
102
107
  * Subscribes to an atom in the current React registry and returns its current
103
108
  * value, optionally mapped through a selector.
104
109
  *
110
+ * **When to use**
111
+ *
112
+ * Use when a React component needs to render from an atom value without also
113
+ * returning a setter.
114
+ *
115
+ * **Details**
116
+ *
117
+ * When a selector is provided, the hook maps the atom before subscribing so the
118
+ * component reads the selected value from the current `RegistryContext`.
119
+ *
120
+ * @see {@link useAtom} for reading and updating a writable atom from one component
121
+ * @see {@link useAtomRef} for reading an `AtomRef` directly
122
+ *
105
123
  * @category hooks
106
124
  * @since 4.0.0
107
125
  */
@@ -110,6 +128,19 @@ export const useAtomValue: {
110
128
  * Subscribes to an atom in the current React registry and returns its current
111
129
  * value, optionally mapped through a selector.
112
130
  *
131
+ * **When to use**
132
+ *
133
+ * Use when a React component needs to render from an atom value without also
134
+ * returning a setter.
135
+ *
136
+ * **Details**
137
+ *
138
+ * When a selector is provided, the hook maps the atom before subscribing so the
139
+ * component reads the selected value from the current `RegistryContext`.
140
+ *
141
+ * @see {@link useAtom} for reading and updating a writable atom from one component
142
+ * @see {@link useAtomRef} for reading an `AtomRef` directly
143
+ *
113
144
  * @category hooks
114
145
  * @since 4.0.0
115
146
  */
@@ -118,6 +149,19 @@ export const useAtomValue: {
118
149
  * Subscribes to an atom in the current React registry and returns its current
119
150
  * value, optionally mapped through a selector.
120
151
  *
152
+ * **When to use**
153
+ *
154
+ * Use when a React component needs to render from an atom value without also
155
+ * returning a setter.
156
+ *
157
+ * **Details**
158
+ *
159
+ * When a selector is provided, the hook maps the atom before subscribing so the
160
+ * component reads the selected value from the current `RegistryContext`.
161
+ *
162
+ * @see {@link useAtom} for reading and updating a writable atom from one component
163
+ * @see {@link useAtomRef} for reading an `AtomRef` directly
164
+ *
121
165
  * @category hooks
122
166
  * @since 4.0.0
123
167
  */
@@ -174,6 +218,20 @@ const flattenExit = <A, E>(exit: Exit.Exit<A, E>): A => {
174
218
  * Mounts an atom in the current React registry for the lifetime of the
175
219
  * component.
176
220
  *
221
+ * **When to use**
222
+ *
223
+ * Use to keep an atom mounted from a React component without reading, writing,
224
+ * or refreshing it.
225
+ *
226
+ * **Details**
227
+ *
228
+ * The hook uses the current `RegistryContext` and releases the mount through
229
+ * React effect cleanup when the component unmounts or when the registry or atom
230
+ * dependency changes.
231
+ *
232
+ * @see {@link useAtomSet} for mounting a writable atom while returning a setter
233
+ * @see {@link useAtomRefresh} for mounting an atom while returning a refresh callback
234
+ *
177
235
  * @category hooks
178
236
  * @since 4.0.0
179
237
  */
@@ -185,6 +243,19 @@ export const useAtomMount = <A>(atom: Atom.Atom<A>): void => {
185
243
  /**
186
244
  * Mounts a writable atom and returns a setter without subscribing to its value.
187
245
  *
246
+ * **When to use**
247
+ *
248
+ * Use when a React component needs to update a writable atom without rendering
249
+ * from that atom's value.
250
+ *
251
+ * **Details**
252
+ *
253
+ * The hook mounts the atom and returns a setter. In value mode the setter
254
+ * accepts a write value or updater function; for `AsyncResult` atoms, `promise`
255
+ * and `promiseExit` modes return a promise for the success value or full `Exit`.
256
+ *
257
+ * @see {@link useAtom} for reading and updating the same writable atom
258
+ *
188
259
  * @category hooks
189
260
  * @since 4.0.0
190
261
  */
@@ -214,6 +285,18 @@ export const useAtomSet = <
214
285
  * Mounts an atom and returns a callback that refreshes it in the current React
215
286
  * registry.
216
287
  *
288
+ * **When to use**
289
+ *
290
+ * Use to expose a React callback that requests a refresh for an atom without
291
+ * reading or writing its value.
292
+ *
293
+ * **Details**
294
+ *
295
+ * The hook uses the current `RegistryContext`, mounts the atom for the
296
+ * component lifetime, and returns a callback that calls `registry.refresh`.
297
+ *
298
+ * @see {@link useAtomMount} for mounting an atom without returning a refresh callback
299
+ *
217
300
  * @category hooks
218
301
  * @since 4.0.0
219
302
  */
@@ -229,6 +312,14 @@ export const useAtomRefresh = <A>(atom: Atom.Atom<A>): () => void => {
229
312
  * Subscribes to a writable atom and returns its current value together with a
230
313
  * setter for updating it.
231
314
  *
315
+ * **When to use**
316
+ *
317
+ * Use when a React component needs both to render the current value of a
318
+ * writable atom and update it from the same component.
319
+ *
320
+ * @see {@link useAtomValue} for subscribing to an atom without a setter
321
+ * @see {@link useAtomSet} for updating a writable atom without subscribing to its value
322
+ *
232
323
  * @category hooks
233
324
  * @since 4.0.0
234
325
  */
@@ -299,6 +390,23 @@ function atomResultOrSuspend<A, E>(
299
390
  * Reads an `AsyncResult` atom through React Suspense, suspending while the
300
391
  * result is initial or configured as waiting.
301
392
  *
393
+ * **When to use**
394
+ *
395
+ * Use when a React component should render only after an `AsyncResult` atom has
396
+ * left its initial state, with loading delegated to a Suspense boundary.
397
+ *
398
+ * **Details**
399
+ *
400
+ * `suspendOnWaiting` defaults to `false`. When `includeFailure` is `true`, a
401
+ * failure result is returned instead of being thrown.
402
+ *
403
+ * **Gotchas**
404
+ *
405
+ * Without `includeFailure`, failure results are thrown with
406
+ * `Cause.squash(result.cause)`, so callers need an error boundary for failures.
407
+ *
408
+ * @see {@link useAtomValue} for reading the raw `AsyncResult` value without Suspense
409
+ *
302
410
  * @category hooks
303
411
  * @since 4.0.0
304
412
  */
@@ -321,6 +429,19 @@ export const useAtomSuspense = <A, E, const IncludeFailure extends boolean = fal
321
429
  * Subscribes a callback to an atom in the current React registry for the
322
430
  * component lifetime.
323
431
  *
432
+ * **When to use**
433
+ *
434
+ * Use when a React component needs to run a callback for atom changes without
435
+ * reading the atom value during render.
436
+ *
437
+ * **Details**
438
+ *
439
+ * The subscription is installed in a React effect and cleaned up on unmount or
440
+ * dependency change. When `options.immediate` is enabled, the callback receives
441
+ * the current value when the effect subscribes.
442
+ *
443
+ * @see {@link useAtomValue} for reading an atom value during render instead of running a callback
444
+ *
324
445
  * @category hooks
325
446
  * @since 4.0.0
326
447
  */
@@ -339,6 +460,19 @@ export const useAtomSubscribe = <A>(
339
460
  /**
340
461
  * Subscribes to an atom ref and returns its latest value.
341
462
  *
463
+ * **When to use**
464
+ *
465
+ * Use when a React component should render from an `AtomRef.ReadonlyRef`
466
+ * directly instead of reading an atom through the current registry.
467
+ *
468
+ * **Details**
469
+ *
470
+ * The hook subscribes with `ref.subscribe`, triggers re-renders through React
471
+ * state, and returns the current `ref.value`.
472
+ *
473
+ * @see {@link useAtomValue} for reading an `Atom` from the current registry
474
+ * @see {@link useAtomRefPropValue} for reading a property ref value
475
+ *
342
476
  * @category hooks
343
477
  * @since 4.0.0
344
478
  */
@@ -351,6 +485,19 @@ export const useAtomRef = <A>(ref: AtomRef.ReadonlyRef<A>): A => {
351
485
  /**
352
486
  * Returns a memoized atom ref for a property of another atom ref.
353
487
  *
488
+ * **When to use**
489
+ *
490
+ * Use to derive an `AtomRef` for one property of an object-shaped atom ref.
491
+ *
492
+ * **Details**
493
+ *
494
+ * The hook memoizes `ref.prop(prop)` for the `[ref, prop]` dependency pair and
495
+ * returns the property ref so callers can read, set, update, or subscribe to
496
+ * that nested property.
497
+ *
498
+ * @see {@link useAtomRef} for subscribing to an atom ref value
499
+ * @see {@link useAtomRefPropValue} for subscribing directly to a property value
500
+ *
354
501
  * @category hooks
355
502
  * @since 4.0.0
356
503
  */
@@ -361,6 +508,20 @@ export const useAtomRefProp = <A, K extends keyof A>(ref: AtomRef.AtomRef<A>, pr
361
508
  * Subscribes to a property ref derived from an atom ref and returns its current
362
509
  * value.
363
510
  *
511
+ * **When to use**
512
+ *
513
+ * Use when a React component needs only the current value of one property from
514
+ * an object-shaped `AtomRef`.
515
+ *
516
+ * **Details**
517
+ *
518
+ * The hook composes `useAtomRefProp(ref, prop)` with `useAtomRef`, so the
519
+ * property ref is memoized for the `[ref, prop]` pair and then subscribed
520
+ * through `ref.subscribe`.
521
+ *
522
+ * @see {@link useAtomRefProp} for returning the property ref directly
523
+ * @see {@link useAtomRef} for subscribing to a whole atom ref value
524
+ *
364
525
  * @category hooks
365
526
  * @since 4.0.0
366
527
  */
@@ -43,12 +43,20 @@ export interface HydrationBoundaryProps {
43
43
  * Hydrates dehydrated Atom values into the current Atom registry for a React
44
44
  * subtree.
45
45
  *
46
+ * **When to use**
47
+ *
48
+ * Use to apply dehydrated Atom state to a React subtree that reads from the
49
+ * nearest `RegistryContext`.
50
+ *
46
51
  * **Details**
47
52
  *
48
53
  * New Atom values are hydrated during render so descendants can read them
49
54
  * immediately, while values for existing Atoms are deferred until after commit
50
55
  * so transition data does not update the current UI before React accepts it.
51
56
  *
57
+ * @see {@link Hydration.dehydrate} for producing dehydrated Atom state
58
+ * @see {@link Hydration.hydrate} for lower-level non-React hydration
59
+ *
52
60
  * @category components
53
61
  * @since 4.0.0
54
62
  */
@@ -47,6 +47,14 @@ export function scheduleTask(f: () => void): () => void {
47
47
  * hydration helpers, defaulting to a standalone registry when no provider is
48
48
  * present.
49
49
  *
50
+ * **When to use**
51
+ *
52
+ * Use to supply an existing `AtomRegistry` through React context when hooks or
53
+ * hydration helpers need to share registry state that is managed outside
54
+ * `RegistryProvider`.
55
+ *
56
+ * @see {@link RegistryProvider} for creating and providing a registry for a React subtree
57
+ *
50
58
  * @category context
51
59
  * @since 4.0.0
52
60
  */
@@ -59,6 +67,25 @@ export const RegistryContext = React.createContext<AtomRegistry.AtomRegistry>(At
59
67
  * Provides a stable `AtomRegistry` to a React subtree, optionally seeding
60
68
  * initial atom values and overriding registry scheduling or idle settings.
61
69
  *
70
+ * **When to use**
71
+ *
72
+ * Use to scope atom state, scheduling, and idle cleanup to a React subtree.
73
+ *
74
+ * **Details**
75
+ *
76
+ * The provider creates one `AtomRegistry` with `AtomRegistry.make`, passes it
77
+ * through `RegistryContext.Provider`, and forwards `initialValues`,
78
+ * `scheduleTask`, `timeoutResolution`, and `defaultIdleTTL` only when that
79
+ * registry is created.
80
+ *
81
+ * **Gotchas**
82
+ *
83
+ * Option changes after the first render do not rebuild the registry. When the
84
+ * provider unmounts, registry disposal is delayed briefly and canceled if the
85
+ * provider remounts before the timeout fires.
86
+ *
87
+ * @see {@link RegistryContext} for the React context supplied by this provider
88
+ *
62
89
  * @category context
63
90
  * @since 4.0.0
64
91
  */
package/src/ScopedAtom.ts CHANGED
@@ -24,7 +24,12 @@ import type * as Atom from "effect/unstable/reactivity/Atom"
24
24
  import * as React from "react"
25
25
 
26
26
  /**
27
- * Type identifier for ScopedAtom.
27
+ * Literal type used as the `ScopedAtom` type identifier.
28
+ *
29
+ * **Details**
30
+ *
31
+ * Used as the computed property key and marker value stored on `ScopedAtom`
32
+ * objects.
28
33
  *
29
34
  * @category type IDs
30
35
  * @since 4.0.0
@@ -34,6 +39,11 @@ export type TypeId = "~@effect/atom-react/ScopedAtom"
34
39
  /**
35
40
  * Type identifier for ScopedAtom.
36
41
  *
42
+ * **Details**
43
+ *
44
+ * Used as the computed property key and marker value stored on `ScopedAtom`
45
+ * objects.
46
+ *
37
47
  * @category type IDs
38
48
  * @since 4.0.0
39
49
  */
@@ -45,15 +55,15 @@ export const TypeId: TypeId = "~@effect/atom-react/ScopedAtom"
45
55
  * **Example** (Providing and reading a scoped atom)
46
56
  *
47
57
  * ```ts
48
- * import * as AtomReact from "@effect/atom-react"
58
+ * import { make, useAtomValue } from "@effect/atom-react"
49
59
  * import { Atom } from "effect/unstable/reactivity"
50
60
  * import * as React from "react"
51
61
  *
52
- * const Counter = AtomReact.make(() => Atom.make(0))
62
+ * const Counter = make(() => Atom.make(0))
53
63
  *
54
64
  * function View() {
55
65
  * const atom = Counter.use()
56
- * const value = AtomReact.useAtomValue(atom)
66
+ * const value = useAtomValue(atom)
57
67
  * return React.createElement("div", null, value)
58
68
  * }
59
69
  *
@@ -76,18 +86,34 @@ export interface ScopedAtom<A extends Atom.Atom<any>, Input = never> {
76
86
  /**
77
87
  * Creates a ScopedAtom from a factory function.
78
88
  *
89
+ * **When to use**
90
+ *
91
+ * Use to create an atom instance that is owned by a React provider and scoped
92
+ * to a component subtree.
93
+ *
94
+ * **Details**
95
+ *
96
+ * The returned scoped atom includes a `Provider`, `Context`, and `use`
97
+ * accessor. The provider creates the atom once for its lifetime, passing the
98
+ * `value` prop to the factory when the scoped atom expects input.
99
+ *
100
+ * **Gotchas**
101
+ *
102
+ * `use` must run under the matching provider. Changing the provider `value`
103
+ * prop after mount does not recreate the atom.
104
+ *
79
105
  * **Example** (Creating a scoped atom with input)
80
106
  *
81
107
  * ```ts
82
- * import * as AtomReact from "@effect/atom-react"
108
+ * import { make, useAtomValue } from "@effect/atom-react"
83
109
  * import { Atom } from "effect/unstable/reactivity"
84
110
  * import * as React from "react"
85
111
  *
86
- * const User = AtomReact.make((name: string) => Atom.make(name))
112
+ * const User = make((name: string) => Atom.make(name))
87
113
  *
88
114
  * function UserName() {
89
115
  * const atom = User.use()
90
- * const value = AtomReact.useAtomValue(atom)
116
+ * const value = useAtomValue(atom)
91
117
  * return React.createElement("span", null, value)
92
118
  * }
93
119
  *