chem-rx 0.0.23 → 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 - 2026-06-13
4
+
5
+ ### Added
6
+
7
+ - Optional `equals` comparator on every atom creation path: `Atom(value, { equals })`,
8
+ `atom.derive(fn, { equals })`, and `atom.select(key, { equals })`. Supply a
9
+ content comparator to dedup notifications by data instead of identity. See
10
+ [Equality & change detection](./README.md#equality--change-detection).
11
+ - `Atom()`'s second argument now also accepts an options object
12
+ (`{ readOnly?, equals? }`) in addition to the legacy `readOnly` boolean.
13
+ - Exported `Equals<T>` and `AtomFactoryOptions<T>` types.
14
+
15
+ ### Changed (breaking)
16
+
17
+ - Every atom now decides whether to notify subscribers using an equality
18
+ comparator that **defaults to `Object.is`**:
19
+ - A base atom no longer re-emits when `next()` is called with an
20
+ `Object.is`-equal value (previously every `next()` notified).
21
+ - `derive` no longer re-emits when its computed output is `Object.is`-equal
22
+ (previously it re-emitted on every parent update).
23
+ - `select` and `combine` are unchanged in practice (already `Object.is`).
24
+
25
+ Migration: pass `equals: () => false` to restore the previous always-notify
26
+ behavior.
package/README.md CHANGED
@@ -1,7 +1,15 @@
1
1
  # chem-rx
2
2
 
3
- `chem-rx` wraps `rxjs` to provide a state management solution focused on
4
- simplicity. Useable with or without React!
3
+ `chem-rx` provides a small atomic state management layer focused on simplicity.
4
+ Useable with or without React!
5
+
6
+ > **Breaking change (unreleased):** atoms now decide whether to notify
7
+ > subscribers using an equality comparator that **defaults to `Object.is`**.
8
+ > Two behaviors changed: a base atom no longer re-emits when you set an
9
+ > `Object.is`-equal value, and `derive` no longer re-emits when its computed
10
+ > output is `Object.is`-equal (it previously always re-emitted on every parent
11
+ > update). To restore the old always-notify behavior, pass `equals: () => false`.
12
+ > See [Equality & change detection](#equality--change-detection).
5
13
 
6
14
  ## Atom
7
15
 
@@ -88,6 +96,15 @@ at that key. Any time the original atom changes, your selected atom will automat
88
96
  This can be especially useful for working with different parts of nested Array and Object atoms.
89
97
 
90
98
  Atoms created with `select` are **read-only** (`ReadOnlyAtom`). This prevents you from modifying original values that the atom was created from.
99
+ Selected atoms are lazy: calling `value()` reads the latest parent snapshot, and subscribing to a selected atom listens to the parent only while that selected atom has active subscribers.
100
+
101
+ By default a selected atom notifies subscribers only when the selected value changes by `Object.is`. Pass `{ equals }` to dedup by content instead (see [Equality & change detection](#equality--change-detection)):
102
+
103
+ ```
104
+ const stacy = students.select("stacy", {
105
+ equals: (a, b) => a?.nickname === b?.nickname,
106
+ });
107
+ ```
91
108
 
92
109
  ```
93
110
  const students = Atom({
@@ -130,6 +147,8 @@ change, your derived atoms will automatically update with new values.
130
147
 
131
148
  Every derived atom is **read-only**. This prevents you from overriding the
132
149
  derived output value, since it is automatically derived from another input.
150
+ Like selected atoms, derived atoms are lazy and only stay subscribed to their
151
+ inputs while they have active subscribers.
133
152
 
134
153
  ```
135
154
  const atom$ = Atom(3);
@@ -138,7 +157,7 @@ const squared$ = atom$.derive((x) => x * x);
138
157
 
139
158
  squared$.value() // "9"
140
159
 
141
- atom$.set(4)
160
+ atom$.next(4)
142
161
 
143
162
  squared$.value() // "16"
144
163
 
@@ -146,19 +165,36 @@ squared$.value() // "16"
146
165
  squared$.set(2)
147
166
  ```
148
167
 
149
- You can optionally enforce `readOnly` on an atom at creation time if needed
168
+ By default, a derived atom notifies subscribers only when its computed output changes by `Object.is`. When `deriveFn` returns a fresh object/array each time (so `Object.is` never matches), pass `{ equals }` to dedup by content (see [Equality & change detection](#equality--change-detection)):
169
+
170
+ ```
171
+ const items$ = data$.derive((data) => data.items, {
172
+ equals: (a, b) => a.length === b.length && a.every((x, i) => x.id === b[i].id),
173
+ });
174
+ ```
175
+
176
+ You can optionally enforce `readOnly` on an atom at creation time if needed. The
177
+ second argument also accepts an options object (`{ readOnly?, equals? }`):
150
178
 
151
179
  ```
152
180
  const atom$ = Atom(3, true);
181
+ // equivalent:
182
+ const atom2$ = Atom(3, { readOnly: true });
153
183
 
154
184
  // ERR: Property 'set' does not exist on type ReadOnlyAtom
155
185
  atom$.set(2)
186
+
187
+ // content-based dedup on a writable atom
188
+ const point$ = Atom({ x: 0, y: 0 }, { equals: (a, b) => a.x === b.x && a.y === b.y });
156
189
  ```
157
190
 
158
191
  ### Combining Atoms
159
192
 
160
193
  Multiple atoms can also be **combined** to create brand new atoms.
161
194
 
195
+ `combine` produces a fresh array snapshot on every input change, so it re-emits on
196
+ every update. To dedup by content, chain a `derive(fn, { equals })` onto it.
197
+
162
198
  Here's an example of joining a set of normalized data models
163
199
 
164
200
  ```
@@ -195,8 +231,14 @@ console.log(mary$.select('pets').value())
195
231
 
196
232
  ### Subscribing to updates
197
233
 
198
- Atoms emit values each time they're updated. You can subscribe callbacks to them
199
- to act on updates
234
+ Atoms emit values each time they change. You can subscribe callbacks to them
235
+ to act on updates.
236
+
237
+ Subscribing fires your callback **immediately** with the atom's current value,
238
+ then again on each subsequent change. "Change" is defined by the atom's equality
239
+ comparator, which **defaults to `Object.is`** — so setting an `Object.is`-equal
240
+ value is deduped and will not re-notify (see
241
+ [Equality & change detection](#equality--change-detection)).
200
242
 
201
243
  ```
202
244
  const atom$ = Atom(3);
@@ -204,13 +246,79 @@ const atom$ = Atom(3);
204
246
  const subscription = atom$.subscribe(val => {
205
247
  console.log("Received value: ", val)
206
248
  })
249
+ // immediately logs "Received value: 3"
207
250
 
208
- atom$.set(4) // "Received value: 4"
251
+ atom$.next(3) // deduped: Object.is-equal, no log
252
+ atom$.next(4) // "Received value: 4"
209
253
 
210
254
  // Unsubscribe to clean up
211
255
  subscription.unsubscribe();
212
256
  ```
213
257
 
258
+ ### Equality & change detection
259
+
260
+ Every atom notifies its subscribers only when its value **changes**, and what
261
+ counts as a "change" is decided by an `equals(previous, next) => boolean`
262
+ comparator. When `equals` returns `true`, the atom still updates `value()` but
263
+ does **not** ping subscribers.
264
+
265
+ The default comparator for every atom — `Atom`, `derive`, `select`, and
266
+ `combine` — is `Object.is`:
267
+
268
+ - For primitives (`number`, `string`, `boolean`, ...) that's value equality.
269
+ - For objects and arrays it's **reference identity** — a brand-new object/array
270
+ is always treated as "changed," even if its contents are identical.
271
+
272
+ #### Reference vs content equality
273
+
274
+ Reference identity is the right default, but it breaks down when a producer
275
+ rebuilds fresh objects/arrays on every update (e.g. a game loop that rebuilds
276
+ its whole scene snapshot each tick). Every snapshot is a new reference, so
277
+ `Object.is` reports "changed" every tick and subscribers fire constantly even
278
+ when nothing meaningful changed.
279
+
280
+ Supply a **content** comparator to fix this:
281
+
282
+ ```
283
+ const tickets$ = frame$.derive(selectTickets, {
284
+ equals: (a, b) =>
285
+ a.length === b.length &&
286
+ a.every((t, i) => t.id === b[i].id && t.status === b[i].status),
287
+ });
288
+ // re-emits only when ticket content actually changes
289
+ ```
290
+
291
+ #### Where you can pass `equals`
292
+
293
+ ```
294
+ Atom(value, { equals }) // base atoms
295
+ parent.derive(fn, { equals }) // derived atoms
296
+ parent.select(key, { equals }) // selected atoms
297
+ ```
298
+
299
+ To force the old "notify on every update" behavior, pass `equals: () => false`.
300
+
301
+ #### You supply the comparator
302
+
303
+ `chem-rx` intentionally ships **no** `shallowEqual`/`deepEqual` helpers. A
304
+ generic shallow equal won't reach into nested or rebuilt structures (the tickets
305
+ example above would still see new element references), and a generic deep equal
306
+ is a correctness trap (`NaN`, `Date`, `Map`/`Set`, cycles, ...). Write the cheap
307
+ field comparison your data actually needs, or stamp a revision/version number on
308
+ the data and compare that.
309
+
310
+ #### React and beyond
311
+
312
+ Because equality lives on the atom (not in a React hook), content dedup benefits
313
+ **every** subscriber — React components, effects, and other derived atoms alike,
314
+ not just renders. React's `useSyncExternalStore` already bails out on
315
+ `Object.is`-equal snapshots; an atom-level `equals` is what gives you the
316
+ additional **content** dedup.
317
+
318
+ > Advanced tip: a memoizing selector that returns the _previous_ reference when
319
+ > the content is equal restores referential stability, so all downstream
320
+ > consumers can dedup off plain `Object.is` after a single comparison.
321
+
214
322
  ### Signals
215
323
 
216
324
  Sometimes, all you want is something to ping you when there's an update. Signals
@@ -256,6 +364,8 @@ You can selectively subscribe to Signals, and selectively ping subscribers by ID
256
364
 
257
365
  ## Use with React
258
366
 
367
+ The root package is headless. React hooks are available from `chem-rx/react`.
368
+
259
369
  ### useAtom
260
370
 
261
371
  `useAtom` automatically updates with new values in your react components.
@@ -264,7 +374,8 @@ If you want to update your atoms, you can simply call the same `next`, `set`, or
264
374
  of react.
265
375
 
266
376
  ```
267
- import { Atom, useAtom } from 'chem-rx'
377
+ import { Atom } from 'chem-rx'
378
+ import { useAtom } from 'chem-rx/react'
268
379
 
269
380
  const count$ = Atom(0)
270
381
 
@@ -273,18 +384,19 @@ function Counter() {
273
384
  return (
274
385
  <h1>
275
386
  {count}
276
- <button onClick={() => count$.set(count$.value() + 1)}>one up</button> ...
387
+ <button onClick={() => count$.next(count$.value() + 1)}>one up</button> ...
277
388
  ```
278
389
 
279
390
  Remember that you can mix and match for any of your needs
280
391
 
281
392
  ### useSelectAtom
282
393
 
283
- With `useSelect` can select a specific key from an atom, and still have it live
394
+ With `useSelectAtom` you can select a specific key from an atom, and still have it live
284
395
  update in your react component.
285
396
 
286
397
  ```
287
- import { Atom, useAtom } from 'chem-rx'
398
+ import { Atom } from 'chem-rx'
399
+ import { useSelectAtom } from 'chem-rx/react'
288
400
 
289
401
  const count$ = Atom({ inner: 0 })
290
402
 
@@ -299,13 +411,14 @@ function Counter() {
299
411
  ### hydrateAtoms
300
412
 
301
413
  With SSR, your atoms will likely need to be properly hydrated to prevent
302
- server/client mismatches. You can use `useHydrateAtoms` as a simple solution for
414
+ server/client mismatches. You can use `hydrateAtoms` as a simple solution for
303
415
  seeding your client-side Atoms with the correct data.
304
416
 
305
417
  NOTE: **`hydrateAtoms` caches values and only runs on the initial load by default**, to prevent re-hydration when client-side only changes are made to the component.
306
418
 
307
419
  ```
308
- import { Atom, useAtom, useHydrateAtoms } from 'chem-rx'
420
+ import { Atom, hydrateAtoms } from 'chem-rx'
421
+ import { useAtom } from 'chem-rx/react'
309
422
 
310
423
  const count$ = Atom(0)
311
424
  const CounterPage = ({ countFromServer }) => {
@@ -372,32 +485,31 @@ There are several suggested "patterns" when using Atoms:
372
485
  6. Name your derived atoms as `<baseAtom>_<derivedValue>$` to easily see which
373
486
  atoms it derives from.
374
487
 
375
- ## Advanced Usage with `rxjs`
488
+ ## Advanced Usage
376
489
 
377
- Behind the scenes, `chem-rx` uses
378
- [rxjs Observables](https://rxjs.dev/guide/operators) to enable reactivity.
379
- `Atom` abstracts away the majority of Rx intentionally, to extract the most
380
- common patterns used when managing front-end data.
490
+ Behind the scenes, `chem-rx` uses a tiny synchronous external-store primitive to
491
+ enable reactivity. `derive`, `select`, and `combine` cover the common state
492
+ composition patterns without requiring a stream library.
381
493
 
382
- If you're coming in with prior experience and are seeking more complex operators
383
- enabled by Rx, you're in luck, because every Atom is simply a wrapper around a
384
- `BehaviorSubject`!
385
-
386
- You can use any rxjs operations you want with `Atom.pipe`, which wraps
387
- `Observable.pipe` to return an Atom.
494
+ If you already have an Observable-like source, you can still create an atom from
495
+ it as long as it has `subscribe` and, ideally, a synchronous `getValue` or
496
+ `value` method for the initial snapshot.
388
497
 
389
498
  ```
390
- import { map } from "rxjs";
391
-
392
- const atom$ = Atom(3);
393
-
394
- // Replace `map` with any operators from rxjs
395
- const squared$: Atom<number> = atom.pipe(map((x) => x * x));
499
+ const source = {
500
+ getValue: () => 3,
501
+ subscribe: (next) => {
502
+ next(3);
503
+ return { unsubscribe: () => {} };
504
+ },
505
+ };
396
506
 
397
- // "9"
398
- console.log(squared$.value());
507
+ const atom$ = Atom(source);
399
508
  ```
400
509
 
401
510
  ## Why...?
402
511
 
403
- [`rxjs`](https://github.com/ReactiveX/rxjs) is awesome, and I wanted a framework-agnostic [jotai](https://github.com/pmndrs/jotai)-like solution with a simpler API.
512
+ I wanted a framework-agnostic [jotai](https://github.com/pmndrs/jotai)-like
513
+ solution with a simpler API. The core atom model does not need a full stream
514
+ library, so `chem-rx` keeps the small atom surface and leaves heavier reactive
515
+ tooling optional.
package/dist/Atom.d.ts CHANGED
@@ -1,71 +1,111 @@
1
- import { BehaviorSubject, Observable, OperatorFunction, Subscription } from "rxjs";
1
+ import { AtomObserver, AtomSource, AtomSubscription } from "./store";
2
2
  export type AtomTuple<T> = {
3
3
  [K in keyof T]: ReadOnlyAtom<T[K]>;
4
4
  };
5
+ type SelectedValue<T, K extends keyof T> = T extends readonly (infer W)[] ? W : T[K];
6
+ type SelectKey<T> = keyof NonNullable<T>;
7
+ type SelectValue<T, K extends SelectKey<T>> = Extract<T, null | undefined> extends never ? SelectedValue<NonNullable<T>, K> : SelectedValue<NonNullable<T>, K> | undefined;
8
+ /**
9
+ * Comparator used to decide whether an atom's value has changed.
10
+ *
11
+ * An atom notifies subscribers only when `equals(previous, next)` returns
12
+ * `false`. The default for every atom is {@link Object.is} (value equality for
13
+ * primitives, reference identity for objects/arrays). Supply a content
14
+ * comparator to dedup by data, or `() => false` to force every update to emit.
15
+ */
16
+ export type Equals<T> = (previousValue: T, nextValue: T) => boolean;
17
+ type AtomOptions<T> = {
18
+ equals?: Equals<T>;
19
+ };
20
+ type AtomDependency<T> = {
21
+ getSnapshot: (force?: boolean) => T;
22
+ subscribe: (onDependencyChange: () => void) => AtomSubscription | (() => void) | void;
23
+ };
5
24
  export declare class ReadOnlyAtom<T> {
6
- _behavior$: BehaviorSubject<T>;
7
- _parent?: BehaviorSubject<T>[];
8
- _bonds: BehaviorSubject<T>[];
9
- _fromObservable: Observable<T> | null;
10
- _fromObservableSubscription: Subscription | null;
11
- constructor(_value: T | Observable<T>);
12
- pipe(): ReadOnlyAtom<T>;
13
- pipe<A>(op1: OperatorFunction<T, A>): ReadOnlyAtom<A>;
14
- pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): ReadOnlyAtom<B>;
15
- pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): ReadOnlyAtom<C>;
16
- pipe<A, B, C, D>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): ReadOnlyAtom<D>;
17
- pipe<A, B, C, D, E>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>): ReadOnlyAtom<E>;
18
- pipe<A, B, C, D, E, F>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>): ReadOnlyAtom<F>;
19
- pipe<A, B, C, D, E, F, G>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>): ReadOnlyAtom<G>;
20
- pipe<A, B, C, D, E, F, G, H>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>): ReadOnlyAtom<H>;
21
- pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>): ReadOnlyAtom<I>;
22
- pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>, ...operations: OperatorFunction<any, any>[]): ReadOnlyAtom<unknown>;
23
- derive<A>(deriveFn: (value: T, index: number) => A): ReadOnlyAtom<A>;
24
- subscribe(...params: Parameters<BehaviorSubject<T>["subscribe"]>): Subscription;
25
+ private _store;
26
+ private _subscriptions;
27
+ private _dependency;
28
+ private _dependencySubscription;
29
+ private _subscriberCount;
30
+ private _equals;
31
+ /**
32
+ * @param options.equals Comparator deciding when the value has changed.
33
+ * Defaults to {@link Object.is}. Subscribers are notified only when it
34
+ * returns `false`.
35
+ */
36
+ constructor(_value: T | AtomSource<T>, dependency?: AtomDependency<T>, options?: AtomOptions<T>);
37
+ /**
38
+ * Create a read-only atom whose value is derived from this atom.
39
+ *
40
+ * By default the derived atom notifies subscribers only when its computed
41
+ * output differs by {@link Object.is}. Pass `options.equals` to dedup by
42
+ * content (useful when `deriveFn` returns a fresh object/array each time), or
43
+ * `equals: () => false` to re-emit on every parent update.
44
+ */
45
+ derive<A>(deriveFn: (value: T, index: number) => A, options?: AtomOptions<A>): ReadOnlyAtom<A>;
46
+ subscribe(observer: AtomObserver<T>): AtomSubscription;
25
47
  value(): T;
26
48
  dispose(): void;
27
- get<K extends keyof T>(key: K): T extends (infer W)[] ? T[number] : T[K];
28
- select<K extends keyof T>(key: K): T[K] extends (infer W)[] ? ArrayAtom<W> : BaseAtom<T[K]>;
49
+ get<K extends SelectKey<T>>(key: K): SelectValue<T, K>;
50
+ /**
51
+ * Create a read-only atom that tracks `key` on this atom's value.
52
+ *
53
+ * By default the selected atom notifies subscribers only when the selected
54
+ * value differs by {@link Object.is}. Pass `options.equals` to dedup by
55
+ * content instead.
56
+ */
57
+ select<K extends SelectKey<T>>(key: K, options?: AtomOptions<SelectValue<T, K>>): ReadOnlyAtom<SelectValue<T, K>>;
58
+ private _refresh;
59
+ private _retainDependency;
60
+ private _releaseDependency;
61
+ /** @internal */
62
+ _next(value: T): void;
63
+ /** @internal */
64
+ _subscribe(observer: AtomObserver<T>, options?: {
65
+ emitImmediately?: boolean;
66
+ }): AtomSubscription;
67
+ /** @internal */
68
+ _addSubscription(subscription: AtomSubscription | (() => void) | void): AtomSubscription;
29
69
  }
30
70
  export declare class BaseAtom<T> extends ReadOnlyAtom<T> {
31
71
  next(nextVal: T): void;
32
- set(nextKey: keyof T, nextValue: T[keyof T]): void;
72
+ set<K extends SelectKey<T>>(nextKey: K, nextValue: NonNullable<T>[K]): void;
33
73
  }
34
- export declare class NullableBaseAtom<T> extends BaseAtom<T> {
35
- constructor(_value?: T | Observable<T>);
36
- get<K extends keyof T>(key: K): (T extends (infer W)[] ? T[number] : T[K]) | undefined;
37
- select<K extends keyof T>(key: K): T extends (infer W)[] ? ArrayAtom<W> : NullableBaseAtom<T[K]>;
74
+ export declare class NullableBaseAtom<T> extends BaseAtom<T | null | undefined> {
75
+ constructor(_value?: T | null | undefined | AtomSource<T | null | undefined>, options?: AtomOptions<T | null | undefined>);
38
76
  next(nextVal: T | null | undefined): void;
39
77
  reset(): void;
40
78
  }
41
79
  export declare class ArrayAtom<T> extends BaseAtom<T[]> {
42
- constructor(initialValue?: T[]);
80
+ constructor(initialValue?: T[] | AtomSource<T[]>, options?: AtomOptions<T[]>);
43
81
  push(nextVal: T): void;
44
82
  }
45
- export declare function Atom<T extends any[]>(value?: Observable<T>): ArrayAtom<T[number]>;
46
- export declare function Atom<T>(value: T extends {
47
- [key in keyof T]: infer V;
48
- } ? Observable<T> : never): BaseAtom<T>;
49
- export declare function Atom<T>(value?: T extends {
50
- [key in keyof T]: infer V;
51
- } ? Observable<T> : never): NullableBaseAtom<T>;
52
- export declare function Atom<T>(value?: T extends {
53
- [key: string]: infer V;
54
- } | any[] ? never : Observable<T>): BaseAtom<T>;
55
- export declare function Atom<T>(value?: T extends {
56
- [key: string]: infer V;
57
- } | any[] ? never : Observable<T>): NullableBaseAtom<T>;
58
- export declare function Atom<T extends any[]>(value?: T): ArrayAtom<T[number]>;
83
+ /**
84
+ * Options for the {@link Atom} factory. `readOnly` produces a
85
+ * {@link ReadOnlyAtom}; `equals` sets the change comparator (defaults to
86
+ * {@link Object.is}).
87
+ */
88
+ export type AtomFactoryOptions<T> = AtomOptions<T> & {
89
+ readOnly?: boolean;
90
+ };
91
+ export declare function Atom<T>(value: T | AtomSource<T>, readOnly: true): ReadOnlyAtom<T>;
92
+ export declare function Atom<T>(value: T | AtomSource<T>, options: AtomFactoryOptions<T> & {
93
+ readOnly: true;
94
+ }): ReadOnlyAtom<T>;
95
+ export declare function Atom<T extends any[]>(value: AtomSource<T>, options?: AtomFactoryOptions<T>): ArrayAtom<T[number]>;
96
+ export declare function Atom<T>(value: AtomSource<T>, options?: AtomFactoryOptions<T>): BaseAtom<T>;
97
+ export declare function Atom<T extends any[]>(value: T, options?: AtomFactoryOptions<T>): ArrayAtom<T[number]>;
59
98
  export declare function Atom<T extends {
60
99
  [key: string]: T[keyof T];
61
- }>(value: T): BaseAtom<T>;
100
+ }>(value: T, options?: AtomFactoryOptions<T>): BaseAtom<T>;
62
101
  export declare function Atom<T extends {
63
102
  [key: string]: T[keyof T];
64
- }>(value?: T): NullableBaseAtom<T>;
65
- export declare function Atom<T>(value: T): BaseAtom<T>;
66
- export declare function Atom<T>(value?: T): NullableBaseAtom<T>;
67
- export declare function Atom<T>(value: T, readOnly?: boolean): ReadOnlyAtom<T>;
103
+ }>(value?: T, options?: AtomFactoryOptions<T>): NullableBaseAtom<T>;
104
+ export declare function Atom<T>(value: T, options?: AtomFactoryOptions<T>): BaseAtom<T>;
105
+ export declare function Atom<T>(value?: T, options?: AtomFactoryOptions<T>): NullableBaseAtom<T>;
106
+ export declare function Atom<T>(value: T | AtomSource<T>, optionsOrReadOnly?: boolean | AtomFactoryOptions<T>): ReadOnlyAtom<T> | BaseAtom<T>;
68
107
  export declare namespace Atom {
69
- var combine: <A extends readonly unknown[]>(...atoms_0: AtomTuple<A>) => ReadOnlyAtom<A>;
108
+ var combine: <A extends readonly unknown[]>(...at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,CAAC,CAAC;AACvB,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAChF,wBAAgB,IAAI,CAAC,CAAC,EACpB,KAAK,CAAC,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC9B,gBAAgB,CAAC,CAAC,CAAC,CAAC;AACvB,wBAAgB,IAAI,CAAC,CAAC,EACpB,KAAK,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EACxB,iBAAiB,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAClD,YAAY,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;yBAHjB,IAAI;kBAyCJ,CAAC,SAAS,SAAS,OAAO,EAAE,6BAEzC,YAAY,CAAC,CAAC,CAAC"}
package/dist/Signal.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { Subscription } from "rxjs";
1
+ import { AtomListener, AtomSubscription } from "./store";
2
2
  export declare class Signal<T = any> {
3
- private _subjects;
4
- private _defaultSubject;
5
- constructor();
3
+ private _listeners;
4
+ private _listenersById;
6
5
  ping(value: T, id?: string): void;
7
- subscribe(callback: (value: T) => void, id?: string): Subscription;
6
+ subscribe(callback: AtomListener<T>, id?: string): AtomSubscription;
8
7
  }
9
8
  //# sourceMappingURL=Signal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../src/Signal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,MAAM,CAAC;AAE7C,qBAAa,MAAM,CAAC,CAAC,GAAG,GAAG;IACzB,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,eAAe,CAAa;;IAOpC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM;IAY1B,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY;CAcnE"}
1
+ {"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../src/Signal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAEjB,qBAAa,MAAM,CAAC,CAAC,GAAG,GAAG;IACzB,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,cAAc,CAAwC;IAE9D,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM;IAa1B,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,gBAAgB;CAqBpE"}