@effect/atom-solid 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
@@ -6,10 +6,16 @@ import type { Accessor, ResourceOptions, ResourceReturn } from "solid-js";
6
6
  /**
7
7
  * Seeds initial atom values in the current Solid atom registry.
8
8
  *
9
+ * **When to use**
10
+ *
11
+ * Use to seed atom values from a Solid component after the current registry
12
+ * already exists.
13
+ *
9
14
  * **Details**
10
15
  *
11
- * Each atom is initialized at most once for a given registry, so subsequent
12
- * computations do not overwrite values that have already been established.
16
+ * For each atom in the current registry, this hook applies the first value
17
+ * supplied through the hook. Later calls for the same atom in that registry are
18
+ * ignored.
13
19
  *
14
20
  * @category hooks
15
21
  * @since 4.0.0
@@ -44,6 +50,20 @@ export declare const useAtomValue: {
44
50
  * Mounts an atom in the current Solid registry for the lifetime of the current
45
51
  * Solid computation.
46
52
  *
53
+ * **When to use**
54
+ *
55
+ * Use to keep an atom mounted from a Solid owner without reading, writing, or
56
+ * refreshing it.
57
+ *
58
+ * **Details**
59
+ *
60
+ * The hook uses the current `RegistryContext`, mounts inside a Solid
61
+ * computation, and releases the mount through Solid cleanup when the
62
+ * computation changes or the owner is disposed.
63
+ *
64
+ * @see {@link useAtomSet} for mounting a writable atom while returning a setter
65
+ * @see {@link useAtomRefresh} for mounting an atom while returning a refresh callback
66
+ *
47
67
  * @category hooks
48
68
  * @since 4.0.0
49
69
  */
@@ -68,6 +88,20 @@ export declare const useAtomRefresh: <A>(atom: () => Atom.Atom<A>) => () => void
68
88
  * Returns a Solid accessor for a writable atom together with a setter for
69
89
  * updating it.
70
90
  *
91
+ * **When to use**
92
+ *
93
+ * Use when a Solid component or computation needs both a reactive accessor for
94
+ * a writable atom and a write function for that same atom.
95
+ *
96
+ * **Details**
97
+ *
98
+ * The setter accepts either a write value or an updater function. For
99
+ * `AsyncResult` atoms, `promise` and `promiseExit` modes return promises for the
100
+ * success value or full `Exit`.
101
+ *
102
+ * @see {@link useAtomValue} for subscribing to an atom without a setter
103
+ * @see {@link useAtomSet} for updating a writable atom without subscribing to its value
104
+ *
71
105
  * @category hooks
72
106
  * @since 4.0.0
73
107
  */
@@ -95,6 +129,21 @@ export declare const useAtomResource: <A, E>(atom: () => Atom.Atom<AsyncResult.A
95
129
  /**
96
130
  * Subscribes to an atom ref and returns its value as a Solid accessor.
97
131
  *
132
+ * **When to use**
133
+ *
134
+ * Use when a Solid component or computation should render from an
135
+ * `AtomRef.ReadonlyRef` directly instead of reading an atom through the current
136
+ * registry.
137
+ *
138
+ * **Details**
139
+ *
140
+ * The hook accepts a thunk for the ref, reads `ref().value`, subscribes with
141
+ * `ref.subscribe`, and releases the subscription through Solid cleanup when
142
+ * the selected ref changes or the owner is disposed.
143
+ *
144
+ * @see {@link useAtomValue} for reading an `Atom` from the current registry
145
+ * @see {@link useAtomRefPropValue} for reading a property ref value
146
+ *
98
147
  * @category hooks
99
148
  * @since 4.0.0
100
149
  */
@@ -102,6 +151,24 @@ export declare const useAtomRef: <A>(ref: () => AtomRef.ReadonlyRef<A>) => Acces
102
151
  /**
103
152
  * Returns a Solid accessor for a property ref derived from an atom ref.
104
153
  *
154
+ * **When to use**
155
+ *
156
+ * Use to derive an `AtomRef` for one property of an object-shaped atom ref in a
157
+ * Solid computation.
158
+ *
159
+ * **Details**
160
+ *
161
+ * The returned accessor memoizes `ref().prop(prop)`, updating when the source
162
+ * ref thunk produces a different ref.
163
+ *
164
+ * **Gotchas**
165
+ *
166
+ * The `prop` argument is captured as a plain value. Recreate the hook call when
167
+ * the property key should change.
168
+ *
169
+ * @see {@link useAtomRef} for subscribing to an atom ref value
170
+ * @see {@link useAtomRefPropValue} for subscribing directly to a property value
171
+ *
105
172
  * @category hooks
106
173
  * @since 4.0.0
107
174
  */
@@ -110,6 +177,24 @@ export declare const useAtomRefProp: <A, K extends keyof A>(ref: () => AtomRef.A
110
177
  * Returns a Solid accessor for the value of a property ref derived from an atom
111
178
  * ref.
112
179
  *
180
+ * **When to use**
181
+ *
182
+ * Use when a Solid component or computation needs the value of one property
183
+ * from an object-shaped `AtomRef` without keeping the intermediate property ref.
184
+ *
185
+ * **Details**
186
+ *
187
+ * The hook composes `useAtomRefProp(ref, prop)` with `useAtomRef`, returning a
188
+ * Solid accessor for the selected property value.
189
+ *
190
+ * **Gotchas**
191
+ *
192
+ * The `prop` argument is captured as a plain value. Recreate the hook call when
193
+ * the property key should change.
194
+ *
195
+ * @see {@link useAtomRef} for subscribing to a whole atom ref value
196
+ * @see {@link useAtomRefProp} for returning the property ref directly
197
+ *
113
198
  * @category hooks
114
199
  * @since 4.0.0
115
200
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Hooks.d.ts","sourceRoot":"","sources":["../src/Hooks.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,WAAW,MAAM,wCAAwC,CAAA;AACrE,OAAO,KAAK,IAAI,MAAM,iCAAiC,CAAA;AACvD,OAAO,KAAK,KAAK,OAAO,MAAM,oCAAoC,CAAA;AAElE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAMzE;;;;;;;;;;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,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC1C;;;;;;OAMG;IACH,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,IAAI,CAAC,C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CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CACzE,CAAA"}
package/dist/Hooks.js CHANGED
@@ -34,10 +34,16 @@ const initialValuesSet = /*#__PURE__*/new WeakMap();
34
34
  /**
35
35
  * Seeds initial atom values in the current Solid atom registry.
36
36
  *
37
+ * **When to use**
38
+ *
39
+ * Use to seed atom values from a Solid component after the current registry
40
+ * already exists.
41
+ *
37
42
  * **Details**
38
43
  *
39
- * Each atom is initialized at most once for a given registry, so subsequent
40
- * computations do not overwrite values that have already been established.
44
+ * For each atom in the current registry, this hook applies the first value
45
+ * supplied through the hook. Later calls for the same atom in that registry are
46
+ * ignored.
41
47
  *
42
48
  * @category hooks
43
49
  * @since 4.0.0
@@ -105,6 +111,20 @@ const flattenExit = exit => {
105
111
  * Mounts an atom in the current Solid registry for the lifetime of the current
106
112
  * Solid computation.
107
113
  *
114
+ * **When to use**
115
+ *
116
+ * Use to keep an atom mounted from a Solid owner without reading, writing, or
117
+ * refreshing it.
118
+ *
119
+ * **Details**
120
+ *
121
+ * The hook uses the current `RegistryContext`, mounts inside a Solid
122
+ * computation, and releases the mount through Solid cleanup when the
123
+ * computation changes or the owner is disposed.
124
+ *
125
+ * @see {@link useAtomSet} for mounting a writable atom while returning a setter
126
+ * @see {@link useAtomRefresh} for mounting an atom while returning a refresh callback
127
+ *
108
128
  * @category hooks
109
129
  * @since 4.0.0
110
130
  */
@@ -139,6 +159,20 @@ export const useAtomRefresh = atom => {
139
159
  * Returns a Solid accessor for a writable atom together with a setter for
140
160
  * updating it.
141
161
  *
162
+ * **When to use**
163
+ *
164
+ * Use when a Solid component or computation needs both a reactive accessor for
165
+ * a writable atom and a write function for that same atom.
166
+ *
167
+ * **Details**
168
+ *
169
+ * The setter accepts either a write value or an updater function. For
170
+ * `AsyncResult` atoms, `promise` and `promiseExit` modes return promises for the
171
+ * success value or full `Exit`.
172
+ *
173
+ * @see {@link useAtomValue} for subscribing to an atom without a setter
174
+ * @see {@link useAtomSet} for updating a writable atom without subscribing to its value
175
+ *
142
176
  * @category hooks
143
177
  * @since 4.0.0
144
178
  */
@@ -179,6 +213,21 @@ const constUnresolvedPromise = /*#__PURE__*/new Promise(() => {});
179
213
  /**
180
214
  * Subscribes to an atom ref and returns its value as a Solid accessor.
181
215
  *
216
+ * **When to use**
217
+ *
218
+ * Use when a Solid component or computation should render from an
219
+ * `AtomRef.ReadonlyRef` directly instead of reading an atom through the current
220
+ * registry.
221
+ *
222
+ * **Details**
223
+ *
224
+ * The hook accepts a thunk for the ref, reads `ref().value`, subscribes with
225
+ * `ref.subscribe`, and releases the subscription through Solid cleanup when
226
+ * the selected ref changes or the owner is disposed.
227
+ *
228
+ * @see {@link useAtomValue} for reading an `Atom` from the current registry
229
+ * @see {@link useAtomRefPropValue} for reading a property ref value
230
+ *
182
231
  * @category hooks
183
232
  * @since 4.0.0
184
233
  */
@@ -194,6 +243,24 @@ export const useAtomRef = ref => {
194
243
  /**
195
244
  * Returns a Solid accessor for a property ref derived from an atom ref.
196
245
  *
246
+ * **When to use**
247
+ *
248
+ * Use to derive an `AtomRef` for one property of an object-shaped atom ref in a
249
+ * Solid computation.
250
+ *
251
+ * **Details**
252
+ *
253
+ * The returned accessor memoizes `ref().prop(prop)`, updating when the source
254
+ * ref thunk produces a different ref.
255
+ *
256
+ * **Gotchas**
257
+ *
258
+ * The `prop` argument is captured as a plain value. Recreate the hook call when
259
+ * the property key should change.
260
+ *
261
+ * @see {@link useAtomRef} for subscribing to an atom ref value
262
+ * @see {@link useAtomRefPropValue} for subscribing directly to a property value
263
+ *
197
264
  * @category hooks
198
265
  * @since 4.0.0
199
266
  */
@@ -202,6 +269,24 @@ export const useAtomRefProp = (ref, prop) => createMemo(() => ref().prop(prop));
202
269
  * Returns a Solid accessor for the value of a property ref derived from an atom
203
270
  * ref.
204
271
  *
272
+ * **When to use**
273
+ *
274
+ * Use when a Solid component or computation needs the value of one property
275
+ * from an object-shaped `AtomRef` without keeping the intermediate property ref.
276
+ *
277
+ * **Details**
278
+ *
279
+ * The hook composes `useAtomRefProp(ref, prop)` with `useAtomRef`, returning a
280
+ * Solid accessor for the selected property value.
281
+ *
282
+ * **Gotchas**
283
+ *
284
+ * The `prop` argument is captured as a plain value. Recreate the hook call when
285
+ * the property key should change.
286
+ *
287
+ * @see {@link useAtomRef} for subscribing to a whole atom ref value
288
+ * @see {@link useAtomRefProp} for returning the property ref directly
289
+ *
205
290
  * @category hooks
206
291
  * @since 4.0.0
207
292
  */
package/dist/Hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Hooks.js","names":["Cause","Effect","Exit","AsyncResult","Atom","AtomRegistry","createComputed","createEffect","createMemo","createResource","createSignal","onCleanup","useContext","RegistryContext","initialValuesSet","WeakMap","useAtomInitialValues","initialValues","registry","set","get","undefined","WeakSet","atom","value","has","add","ensureNode","setValue","useAtomValue","f","createAtomAccessor","map","subscribe","constImmediate","immediate","mountAtom","mount","setAtom","options","memo","mode","promise","runPromiseExit","getResult","suspendOnWaiting","then","flattenExit","exit","isSuccess","squash","cause","useAtomMount","useAtomSet","useAtomRefresh","refresh","useAtom","useAtomSubscribe","useAtomResource","result","isInitial","waiting","constUnresolvedPromise","Promise","resolve","reject","useAtomRef","ref","r","useAtomRefProp","prop","useAtomRefPropValue"],"sources":["../src/Hooks.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,WAAW,MAAM,wCAAwC;AACrE,OAAO,KAAKC,IAAI,MAAM,iCAAiC;AAEvD,OAAO,KAAKC,YAAY,MAAM,yCAAyC;AAEvE,SAASC,cAAc,EAAE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M6C,cAAc,GAAGA,CAC5BF,GAA6B,EAC7BG,IAAO,KAC6B9D,UAAU,CAAC,MAAM2D,GAAG,EAAE,CAACG,IAAI,CAACA,IAAI,CAAC,CAAC;AAExE;;;;;;;AAOA,OAAO,MAAMC,mBAAmB,GAAGA,CAAuBJ,GAA6B,EAAEG,IAAO,KAC9FJ,UAAU,CAACG,cAAc,CAACF,GAAG,EAAEG,IAAI,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Hooks.js","names":["Cause","Effect","Exit","AsyncResult","Atom","AtomRegistry","createComputed","createEffect","createMemo","createResource","createSignal","onCleanup","useContext","RegistryContext","initialValuesSet","WeakMap","useAtomInitialValues","initialValues","registry","set","get","undefined","WeakSet","atom","value","has","add","ensureNode","setValue","useAtomValue","f","createAtomAccessor","map","subscribe","constImmediate","immediate","mountAtom","mount","setAtom","options","memo","mode","promise","runPromiseExit","getResult","suspendOnWaiting","then","flattenExit","exit","isSuccess","squash","cause","useAtomMount","useAtomSet","useAtomRefresh","refresh","useAtom","useAtomSubscribe","useAtomResource","result","isInitial","waiting","constUnresolvedPromise","Promise","resolve","reject","useAtomRef","ref","r","useAtomRefProp","prop","useAtomRefPropValue"],"sources":["../src/Hooks.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,WAAW,MAAM,wCAAwC;AACrE,OAAO,KAAKC,IAAI,MAAM,iCAAiC;AAEvD,OAAO,KAAKC,YAAY,MAAM,yCAAyC;AAEvE,SAASC,cAAc,EAAEC,YAAY,EAAEC,UAAU,EAAEC,cAAc,EAAEC,YAAY,EAAEC,SAAS,EAAEC,UAAU,QAAQ,UAAU;AACxH,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,MAAMC,gBAAgB,gBAAG,IAAI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MAAM2D,GAAG,EAAE,CAACG,IAAI,CAACA,IAAI,CAAC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,MAAMC,mBAAmB,GAAGA,CAAuBJ,GAA6B,EAAEG,IAAO,KAC9FJ,UAAU,CAACG,cAAc,CAACF,GAAG,EAAEG,IAAI,CAAC,CAAC","ignoreList":[]}
@@ -30,6 +30,17 @@ import type { JSX } from "solid-js";
30
30
  * A Solid context that carries the `AtomRegistry` used by atom hooks in the
31
31
  * current owner tree.
32
32
  *
33
+ * **When to use**
34
+ *
35
+ * Use when integrating lower-level Solid atom APIs that need direct access to,
36
+ * or direct provisioning of, the `AtomRegistry` for the current owner tree.
37
+ *
38
+ * **Details**
39
+ *
40
+ * When no provider is present, the context uses a standalone default registry.
41
+ *
42
+ * @see {@link RegistryProvider} for creating and providing a registry for a Solid subtree
43
+ *
33
44
  * @category context
34
45
  * @since 4.0.0
35
46
  */
@@ -39,6 +50,24 @@ export declare const RegistryContext: import("solid-js").Context<AtomRegistry.At
39
50
  * values and scheduler settings, and disposes the registry when the owner is
40
51
  * cleaned up.
41
52
  *
53
+ * **When to use**
54
+ *
55
+ * Use to scope atom state, scheduling, and cleanup to a Solid subtree.
56
+ *
57
+ * **Details**
58
+ *
59
+ * The provider creates an `AtomRegistry` with `AtomRegistry.make`, forwards
60
+ * `initialValues`, `scheduleTask`, `timeoutResolution`, and
61
+ * `defaultIdleTTL`, and supplies the registry through `RegistryContext`.
62
+ *
63
+ * **Gotchas**
64
+ *
65
+ * Provider options are consumed when the registry is created; they are not
66
+ * reactive updates. A custom `scheduleTask` should return a cancellation
67
+ * function that is safe to call during Solid cleanup.
68
+ *
69
+ * @see {@link RegistryContext} for the context supplied by this provider
70
+ *
42
71
  * @category context
43
72
  * @since 4.0.0
44
73
  */
@@ -1 +1 @@
1
- {"version":3,"file":"RegistryContext.d.ts","sourceRoot":"","sources":["../src/RegistryContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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CAAC,OAAO,GAAG,SAAS,CAAA;IAC3C,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,gBAcA,CAAA"}
@@ -4,6 +4,17 @@ import { createComponent, createContext, onCleanup } from "solid-js";
4
4
  * A Solid context that carries the `AtomRegistry` used by atom hooks in the
5
5
  * current owner tree.
6
6
  *
7
+ * **When to use**
8
+ *
9
+ * Use when integrating lower-level Solid atom APIs that need direct access to,
10
+ * or direct provisioning of, the `AtomRegistry` for the current owner tree.
11
+ *
12
+ * **Details**
13
+ *
14
+ * When no provider is present, the context uses a standalone default registry.
15
+ *
16
+ * @see {@link RegistryProvider} for creating and providing a registry for a Solid subtree
17
+ *
7
18
  * @category context
8
19
  * @since 4.0.0
9
20
  */
@@ -13,6 +24,24 @@ export const RegistryContext = /*#__PURE__*/createContext(/*#__PURE__*/AtomRegis
13
24
  * values and scheduler settings, and disposes the registry when the owner is
14
25
  * cleaned up.
15
26
  *
27
+ * **When to use**
28
+ *
29
+ * Use to scope atom state, scheduling, and cleanup to a Solid subtree.
30
+ *
31
+ * **Details**
32
+ *
33
+ * The provider creates an `AtomRegistry` with `AtomRegistry.make`, forwards
34
+ * `initialValues`, `scheduleTask`, `timeoutResolution`, and
35
+ * `defaultIdleTTL`, and supplies the registry through `RegistryContext`.
36
+ *
37
+ * **Gotchas**
38
+ *
39
+ * Provider options are consumed when the registry is created; they are not
40
+ * reactive updates. A custom `scheduleTask` should return a cancellation
41
+ * function that is safe to call during Solid cleanup.
42
+ *
43
+ * @see {@link RegistryContext} for the context supplied by this provider
44
+ *
16
45
  * @category context
17
46
  * @since 4.0.0
18
47
  */
@@ -1 +1 @@
1
- {"version":3,"file":"RegistryContext.js","names":["AtomRegistry","createComponent","createContext","onCleanup","RegistryContext","make","RegistryProvider","options","registry","scheduleTask","initialValues","timeoutResolution","defaultIdleTTL","dispose","Provider","value","children"],"sources":["../src/RegistryContext.ts"],"sourcesContent":[null],"mappings":"AA0BA,OAAO,KAAKA,YAAY,MAAM,yCAAyC;AAEvE,SAASC,eAAe,EAAEC,aAAa,EAAEC,SAAS,QAAQ,UAAU;AAEpE;;;;;;;AAOA,OAAO,MAAMC,eAAe,gBAAGF,aAAa,cAA4BF,YAAY,CAACK,IAAI,EAAE,CAAC;AAE5F;;;;;;;;AAQA,OAAO,MAAMC,gBAAgB,GAAIC,OAMhC,IAAI;EACH,MAAMC,QAAQ,GAAGR,YAAY,CAACK,IAAI,CAAC;IACjCI,YAAY,EAAEF,OAAO,CAACE,YAAY;IAClCC,aAAa,EAAEH,OAAO,CAACG,aAAa;IACpCC,iBAAiB,EAAEJ,OAAO,CAACI,iBAAiB;IAC5CC,cAAc,EAAEL,OAAO,CAACK,cAAc,IAAI;GAC3C,CAAC;EACFT,SAAS,CAAC,MAAMK,QAAQ,CAACK,OAAO,EAAE,CAAC;EACnC,OAAOZ,eAAe,CAACG,eAAe,CAACU,QAAQ,EAAE;IAC/CC,KAAK,EAAEP,QAAQ;IACf,IAAIQ,QAAQA,CAAA;MACV,OAAOT,OAAO,CAACS,QAAQ;IACzB;GACD,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"RegistryContext.js","names":["AtomRegistry","createComponent","createContext","onCleanup","RegistryContext","make","RegistryProvider","options","registry","scheduleTask","initialValues","timeoutResolution","defaultIdleTTL","dispose","Provider","value","children"],"sources":["../src/RegistryContext.ts"],"sourcesContent":[null],"mappings":"AA0BA,OAAO,KAAKA,YAAY,MAAM,yCAAyC;AAEvE,SAASC,eAAe,EAAEC,aAAa,EAAEC,SAAS,QAAQ,UAAU;AAEpE;;;;;;;;;;;;;;;;;;AAkBA,OAAO,MAAMC,eAAe,gBAAGF,aAAa,cAA4BF,YAAY,CAACK,IAAI,EAAE,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,OAAO,MAAMC,gBAAgB,GAAIC,OAMhC,IAAI;EACH,MAAMC,QAAQ,GAAGR,YAAY,CAACK,IAAI,CAAC;IACjCI,YAAY,EAAEF,OAAO,CAACE,YAAY;IAClCC,aAAa,EAAEH,OAAO,CAACG,aAAa;IACpCC,iBAAiB,EAAEJ,OAAO,CAACI,iBAAiB;IAC5CC,cAAc,EAAEL,OAAO,CAACK,cAAc,IAAI;GAC3C,CAAC;EACFT,SAAS,CAAC,MAAMK,QAAQ,CAACK,OAAO,EAAE,CAAC;EACnC,OAAOZ,eAAe,CAACG,eAAe,CAACU,QAAQ,EAAE;IAC/CC,KAAK,EAAEP,QAAQ;IACf,IAAIQ,QAAQA,CAAA;MACV,OAAOT,OAAO,CAACS,QAAQ;IACzB;GACD,CAAC;AACJ,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/atom-solid",
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": "SolidJS bindings for the Effect Atom modules",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "peerDependencies": {
46
46
  "solid-js": ">=1 <2",
47
- "effect": "^4.0.0-beta.70"
47
+ "effect": "^4.0.0-beta.71"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@solidjs/testing-library": "^0.8.0",
@@ -52,7 +52,7 @@
52
52
  "@testing-library/jest-dom": "^6.9.1",
53
53
  "jsdom": "^29.1.1",
54
54
  "solid-js": "^1.9.12",
55
- "effect": "^4.0.0-beta.70"
55
+ "effect": "^4.0.0-beta.71"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsc -b tsconfig.json && pnpm babel",
package/src/Hooks.ts CHANGED
@@ -38,10 +38,16 @@ const initialValuesSet = new WeakMap<AtomRegistry.AtomRegistry, WeakSet<Atom.Ato
38
38
  /**
39
39
  * Seeds initial atom values in the current Solid atom registry.
40
40
  *
41
+ * **When to use**
42
+ *
43
+ * Use to seed atom values from a Solid component after the current registry
44
+ * already exists.
45
+ *
41
46
  * **Details**
42
47
  *
43
- * Each atom is initialized at most once for a given registry, so subsequent
44
- * computations do not overwrite values that have already been established.
48
+ * For each atom in the current registry, this hook applies the first value
49
+ * supplied through the hook. Later calls for the same atom in that registry are
50
+ * ignored.
45
51
  *
46
52
  * @category hooks
47
53
  * @since 4.0.0
@@ -146,6 +152,20 @@ const flattenExit = <A, E>(exit: Exit.Exit<A, E>): A => {
146
152
  * Mounts an atom in the current Solid registry for the lifetime of the current
147
153
  * Solid computation.
148
154
  *
155
+ * **When to use**
156
+ *
157
+ * Use to keep an atom mounted from a Solid owner without reading, writing, or
158
+ * refreshing it.
159
+ *
160
+ * **Details**
161
+ *
162
+ * The hook uses the current `RegistryContext`, mounts inside a Solid
163
+ * computation, and releases the mount through Solid cleanup when the
164
+ * computation changes or the owner is disposed.
165
+ *
166
+ * @see {@link useAtomSet} for mounting a writable atom while returning a setter
167
+ * @see {@link useAtomRefresh} for mounting an atom while returning a refresh callback
168
+ *
149
169
  * @category hooks
150
170
  * @since 4.0.0
151
171
  */
@@ -199,6 +219,20 @@ export const useAtomRefresh = <A>(atom: () => Atom.Atom<A>): () => void => {
199
219
  * Returns a Solid accessor for a writable atom together with a setter for
200
220
  * updating it.
201
221
  *
222
+ * **When to use**
223
+ *
224
+ * Use when a Solid component or computation needs both a reactive accessor for
225
+ * a writable atom and a write function for that same atom.
226
+ *
227
+ * **Details**
228
+ *
229
+ * The setter accepts either a write value or an updater function. For
230
+ * `AsyncResult` atoms, `promise` and `promiseExit` modes return promises for the
231
+ * success value or full `Exit`.
232
+ *
233
+ * @see {@link useAtomValue} for subscribing to an atom without a setter
234
+ * @see {@link useAtomSet} for updating a writable atom without subscribing to its value
235
+ *
202
236
  * @category hooks
203
237
  * @since 4.0.0
204
238
  */
@@ -269,6 +303,21 @@ const constUnresolvedPromise = new Promise<never>(() => {})
269
303
  /**
270
304
  * Subscribes to an atom ref and returns its value as a Solid accessor.
271
305
  *
306
+ * **When to use**
307
+ *
308
+ * Use when a Solid component or computation should render from an
309
+ * `AtomRef.ReadonlyRef` directly instead of reading an atom through the current
310
+ * registry.
311
+ *
312
+ * **Details**
313
+ *
314
+ * The hook accepts a thunk for the ref, reads `ref().value`, subscribes with
315
+ * `ref.subscribe`, and releases the subscription through Solid cleanup when
316
+ * the selected ref changes or the owner is disposed.
317
+ *
318
+ * @see {@link useAtomValue} for reading an `Atom` from the current registry
319
+ * @see {@link useAtomRefPropValue} for reading a property ref value
320
+ *
272
321
  * @category hooks
273
322
  * @since 4.0.0
274
323
  */
@@ -285,6 +334,24 @@ export const useAtomRef = <A>(ref: () => AtomRef.ReadonlyRef<A>): Accessor<A> =>
285
334
  /**
286
335
  * Returns a Solid accessor for a property ref derived from an atom ref.
287
336
  *
337
+ * **When to use**
338
+ *
339
+ * Use to derive an `AtomRef` for one property of an object-shaped atom ref in a
340
+ * Solid computation.
341
+ *
342
+ * **Details**
343
+ *
344
+ * The returned accessor memoizes `ref().prop(prop)`, updating when the source
345
+ * ref thunk produces a different ref.
346
+ *
347
+ * **Gotchas**
348
+ *
349
+ * The `prop` argument is captured as a plain value. Recreate the hook call when
350
+ * the property key should change.
351
+ *
352
+ * @see {@link useAtomRef} for subscribing to an atom ref value
353
+ * @see {@link useAtomRefPropValue} for subscribing directly to a property value
354
+ *
288
355
  * @category hooks
289
356
  * @since 4.0.0
290
357
  */
@@ -297,6 +364,24 @@ export const useAtomRefProp = <A, K extends keyof A>(
297
364
  * Returns a Solid accessor for the value of a property ref derived from an atom
298
365
  * ref.
299
366
  *
367
+ * **When to use**
368
+ *
369
+ * Use when a Solid component or computation needs the value of one property
370
+ * from an object-shaped `AtomRef` without keeping the intermediate property ref.
371
+ *
372
+ * **Details**
373
+ *
374
+ * The hook composes `useAtomRefProp(ref, prop)` with `useAtomRef`, returning a
375
+ * Solid accessor for the selected property value.
376
+ *
377
+ * **Gotchas**
378
+ *
379
+ * The `prop` argument is captured as a plain value. Recreate the hook call when
380
+ * the property key should change.
381
+ *
382
+ * @see {@link useAtomRef} for subscribing to a whole atom ref value
383
+ * @see {@link useAtomRefProp} for returning the property ref directly
384
+ *
300
385
  * @category hooks
301
386
  * @since 4.0.0
302
387
  */
@@ -32,6 +32,17 @@ import { createComponent, createContext, onCleanup } from "solid-js"
32
32
  * A Solid context that carries the `AtomRegistry` used by atom hooks in the
33
33
  * current owner tree.
34
34
  *
35
+ * **When to use**
36
+ *
37
+ * Use when integrating lower-level Solid atom APIs that need direct access to,
38
+ * or direct provisioning of, the `AtomRegistry` for the current owner tree.
39
+ *
40
+ * **Details**
41
+ *
42
+ * When no provider is present, the context uses a standalone default registry.
43
+ *
44
+ * @see {@link RegistryProvider} for creating and providing a registry for a Solid subtree
45
+ *
35
46
  * @category context
36
47
  * @since 4.0.0
37
48
  */
@@ -42,6 +53,24 @@ export const RegistryContext = createContext<AtomRegistry.AtomRegistry>(AtomRegi
42
53
  * values and scheduler settings, and disposes the registry when the owner is
43
54
  * cleaned up.
44
55
  *
56
+ * **When to use**
57
+ *
58
+ * Use to scope atom state, scheduling, and cleanup to a Solid subtree.
59
+ *
60
+ * **Details**
61
+ *
62
+ * The provider creates an `AtomRegistry` with `AtomRegistry.make`, forwards
63
+ * `initialValues`, `scheduleTask`, `timeoutResolution`, and
64
+ * `defaultIdleTTL`, and supplies the registry through `RegistryContext`.
65
+ *
66
+ * **Gotchas**
67
+ *
68
+ * Provider options are consumed when the registry is created; they are not
69
+ * reactive updates. A custom `scheduleTask` should return a cancellation
70
+ * function that is safe to call during Solid cleanup.
71
+ *
72
+ * @see {@link RegistryContext} for the context supplied by this provider
73
+ *
45
74
  * @category context
46
75
  * @since 4.0.0
47
76
  */