effect-atom-svelte 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -10,7 +10,7 @@ This is a community project by Jarred Norris. It is not part of Effect, and the
10
10
 
11
11
  - `effect` 4.0.x. The peer range is `~4.0.0`, not `^4.0.0`: the bindings use parts of the atom registry that aren't public API, which a minor release of `effect` can change.
12
12
  - Svelte 5.57.2 or later. `experimental.async` is needed for `useAtomSuspense`, `useAtomResult` and server rendering.
13
- - SvelteKit is optional. The docs site and its tests run on SvelteKit 3. On SvelteKit 2, the error hooks in `effect-atom-svelte/sveltekit` work with less detail.
13
+ - SvelteKit is optional. The docs site and its tests run on SvelteKit 3. On SvelteKit 2, the error hooks in `effect-atom-svelte/sveltekit` work with less detail, and reach `<svelte:boundary>` only with `kit.experimental.handleRenderingErrors` turned on.
14
14
 
15
15
  ## Installation
16
16
 
@@ -122,12 +122,14 @@ export declare const useAtomMount: (input: AtomInput<Atom.Atom<unknown>>) => voi
122
122
  *
123
123
  * In `promise` and `promiseExit` modes the setter waits for the atom's next settled result. The
124
124
  * wait holds the atom, so a call still in flight keeps it running after the component is
125
- * destroyed, until it settles. The call's `signal` cancels only the wait: an `Atom.fn` already
125
+ * destroyed, until it settles, unless the `RegistryProvider` that created the registry is
126
+ * destroyed: that interrupts the call and settles it as interrupted. The call's `signal` cancels only the wait: an `Atom.fn` already
126
127
  * running keeps going (send `Atom.Interrupt` to stop it). A signal that is already aborted settles
127
128
  * the call as interrupted without writing, as `fetch` does. Calls on one `Atom.fn` share its single
128
129
  * result, so a new call supersedes one in flight and every pending call resolves with the latest
129
130
  * call's result. `Atom.Reset` has no result to wait for, so these modes leave it out of their
130
- * types and reject it; reset with a `value` mode setter.
131
+ * types and reject it; reset with a `value` mode setter. A reset written while a promise-mode call
132
+ * is pending settles that promise as interrupted. To cancel a call, send `Atom.Interrupt`.
131
133
  *
132
134
  * **Example** (Updating an atom from its current value)
133
135
  *
@@ -207,9 +209,10 @@ export declare const useAtomSubscribe: <A>(input: AtomInput<Atom.Atom<A>>, f: (v
207
209
  * an atom that can only compute in the browser can start from a value on the server.
208
210
  *
209
211
  * A value applies once while the atom is held, so a component mounted later, or a second
210
- * component with its own value, does not overwrite a value the atom has moved on from. Once nothing
211
- * holds the atom and the registry disposes it, the next component to start it applies its value
212
- * again. On the server a value lasts one render, so each request against a shared registry applies
212
+ * component with its own value, does not overwrite a value the atom has moved on from since the
213
+ * first applied one. An atom that is already in use without one, read by another component, is set
214
+ * to the value, as `@effect/atom-react` does. Once nothing holds the atom and the registry disposes
215
+ * it, the next component to start it applies its value again. On the server a value lasts one render, so each request against a shared registry applies
213
216
  * its own; requests rendering at the same time share the registry's atoms, and with them the value
214
217
  * the first one applied.
215
218
  *
@@ -232,8 +235,9 @@ export declare const useAtomSubscribe: <A>(input: AtomInput<Atom.Atom<A>>, f: (v
232
235
  */
233
236
  export declare const useAtomInitialValues: (initialValues: Iterable<readonly [Atom.Atom<unknown>, unknown]>) => void;
234
237
  /**
235
- * Reads an `AtomRef`, following it when the getter returns a different ref. For one property of a
236
- * ref, use `useAtomRefPropValue`.
238
+ * Reads an `AtomRef`, following it when the getter returns a different ref. For a writable ref,
239
+ * `current` can be assigned too, which sets the ref, so `bind:value={name.current}` works; a
240
+ * read-only ref, as from `map`, can't be. For one property of a ref, use `useAtomRefPropValue`.
237
241
  *
238
242
  * A ref has no registry. On the server, one created at module level is shared by every request,
239
243
  * so don't write a visitor's data to it there: see
@@ -253,7 +257,8 @@ export declare const useAtomInitialValues: (initialValues: Iterable<readonly [At
253
257
  * @since 0.1.0
254
258
  * @category hooks
255
259
  */
256
- export declare const useAtomRef: <A>(input: AtomInput<AtomRef.ReadonlyRef<A>>) => AtomValue<A>;
260
+ export declare function useAtomRef<A>(input: AtomInput<AtomRef.AtomRef<A>>): AtomState<A>;
261
+ export declare function useAtomRef<A>(input: AtomInput<AtomRef.ReadonlyRef<A>>): AtomValue<A>;
257
262
  /**
258
263
  * Returns `ref.prop(prop)`, the `AtomRef` for one property of an `AtomRef`. It takes the ref
259
264
  * itself, not a getter, and does not follow later changes to `ref` or `prop`; to read a property
@@ -276,7 +281,8 @@ export declare const useAtomRef: <A>(input: AtomInput<AtomRef.ReadonlyRef<A>>) =
276
281
  export declare const useAtomRefProp: <A, K extends keyof A>(ref: AtomRef.AtomRef<A>, prop: K) => AtomRef.AtomRef<A[K]>;
277
282
  /**
278
283
  * Reads one property of an `AtomRef`, following the getter to a different ref. `prop` is taken
279
- * once, when the component starts, and is not followed.
284
+ * once, when the component starts, and is not followed. Assigning `current` sets the property, so
285
+ * `bind:checked={done.current}` works.
280
286
  *
281
287
  * **Example** (Reading one property of a ref)
282
288
  *
@@ -292,7 +298,7 @@ export declare const useAtomRefProp: <A, K extends keyof A>(ref: AtomRef.AtomRef
292
298
  * @since 0.1.0
293
299
  * @category hooks
294
300
  */
295
- export declare const useAtomRefPropValue: <A, K extends keyof A>(input: AtomInput<AtomRef.AtomRef<A>>, prop: K) => AtomValue<A[K]>;
301
+ export declare const useAtomRefPropValue: <A, K extends keyof A>(input: AtomInput<AtomRef.AtomRef<A>>, prop: K) => AtomState<A[K]>;
296
302
  /**
297
303
  * Options for `useAtomResult`.
298
304
  *