chem-rx 0.0.23 → 0.1.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
@@ -1,7 +1,7 @@
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
5
 
6
6
  ## Atom
7
7
 
@@ -88,6 +88,7 @@ at that key. Any time the original atom changes, your selected atom will automat
88
88
  This can be especially useful for working with different parts of nested Array and Object atoms.
89
89
 
90
90
  Atoms created with `select` are **read-only** (`ReadOnlyAtom`). This prevents you from modifying original values that the atom was created from.
91
+ 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.
91
92
 
92
93
  ```
93
94
  const students = Atom({
@@ -130,6 +131,8 @@ change, your derived atoms will automatically update with new values.
130
131
 
131
132
  Every derived atom is **read-only**. This prevents you from overriding the
132
133
  derived output value, since it is automatically derived from another input.
134
+ Like selected atoms, derived atoms are lazy and only stay subscribed to their
135
+ inputs while they have active subscribers.
133
136
 
134
137
  ```
135
138
  const atom$ = Atom(3);
@@ -138,7 +141,7 @@ const squared$ = atom$.derive((x) => x * x);
138
141
 
139
142
  squared$.value() // "9"
140
143
 
141
- atom$.set(4)
144
+ atom$.next(4)
142
145
 
143
146
  squared$.value() // "16"
144
147
 
@@ -256,6 +259,8 @@ You can selectively subscribe to Signals, and selectively ping subscribers by ID
256
259
 
257
260
  ## Use with React
258
261
 
262
+ The root package is headless. React hooks are available from `chem-rx/react`.
263
+
259
264
  ### useAtom
260
265
 
261
266
  `useAtom` automatically updates with new values in your react components.
@@ -264,7 +269,8 @@ If you want to update your atoms, you can simply call the same `next`, `set`, or
264
269
  of react.
265
270
 
266
271
  ```
267
- import { Atom, useAtom } from 'chem-rx'
272
+ import { Atom } from 'chem-rx'
273
+ import { useAtom } from 'chem-rx/react'
268
274
 
269
275
  const count$ = Atom(0)
270
276
 
@@ -273,18 +279,19 @@ function Counter() {
273
279
  return (
274
280
  <h1>
275
281
  {count}
276
- <button onClick={() => count$.set(count$.value() + 1)}>one up</button> ...
282
+ <button onClick={() => count$.next(count$.value() + 1)}>one up</button> ...
277
283
  ```
278
284
 
279
285
  Remember that you can mix and match for any of your needs
280
286
 
281
287
  ### useSelectAtom
282
288
 
283
- With `useSelect` can select a specific key from an atom, and still have it live
289
+ With `useSelectAtom` you can select a specific key from an atom, and still have it live
284
290
  update in your react component.
285
291
 
286
292
  ```
287
- import { Atom, useAtom } from 'chem-rx'
293
+ import { Atom } from 'chem-rx'
294
+ import { useSelectAtom } from 'chem-rx/react'
288
295
 
289
296
  const count$ = Atom({ inner: 0 })
290
297
 
@@ -299,13 +306,14 @@ function Counter() {
299
306
  ### hydrateAtoms
300
307
 
301
308
  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
309
+ server/client mismatches. You can use `hydrateAtoms` as a simple solution for
303
310
  seeding your client-side Atoms with the correct data.
304
311
 
305
312
  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
313
 
307
314
  ```
308
- import { Atom, useAtom, useHydrateAtoms } from 'chem-rx'
315
+ import { Atom, hydrateAtoms } from 'chem-rx'
316
+ import { useAtom } from 'chem-rx/react'
309
317
 
310
318
  const count$ = Atom(0)
311
319
  const CounterPage = ({ countFromServer }) => {
@@ -372,32 +380,31 @@ There are several suggested "patterns" when using Atoms:
372
380
  6. Name your derived atoms as `<baseAtom>_<derivedValue>$` to easily see which
373
381
  atoms it derives from.
374
382
 
375
- ## Advanced Usage with `rxjs`
376
-
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.
383
+ ## Advanced Usage
381
384
 
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
+ Behind the scenes, `chem-rx` uses a tiny synchronous external-store primitive to
386
+ enable reactivity. `derive`, `select`, and `combine` cover the common state
387
+ composition patterns without requiring a stream library.
385
388
 
386
- You can use any rxjs operations you want with `Atom.pipe`, which wraps
387
- `Observable.pipe` to return an Atom.
389
+ If you already have an Observable-like source, you can still create an atom from
390
+ it as long as it has `subscribe` and, ideally, a synchronous `getValue` or
391
+ `value` method for the initial snapshot.
388
392
 
389
393
  ```
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));
394
+ const source = {
395
+ getValue: () => 3,
396
+ subscribe: (next) => {
397
+ next(3);
398
+ return { unsubscribe: () => {} };
399
+ },
400
+ };
396
401
 
397
- // "9"
398
- console.log(squared$.value());
402
+ const atom$ = Atom(source);
399
403
  ```
400
404
 
401
405
  ## Why...?
402
406
 
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.
407
+ I wanted a framework-agnostic [jotai](https://github.com/pmndrs/jotai)-like
408
+ solution with a simpler API. The core atom model does not need a full stream
409
+ library, so `chem-rx` keeps the small atom surface and leaves heavier reactive
410
+ tooling optional.
package/dist/Atom.d.ts CHANGED
@@ -1,60 +1,56 @@
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
+ type AtomDependency<T> = {
9
+ getSnapshot: (force?: boolean) => T;
10
+ subscribe: (onDependencyChange: () => void) => AtomSubscription | (() => void) | void;
11
+ shouldNotify?: (previousValue: T, nextValue: T) => boolean;
12
+ };
5
13
  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>;
14
+ private _store;
15
+ private _subscriptions;
16
+ private _dependency;
17
+ private _dependencySubscription;
18
+ private _subscriberCount;
19
+ constructor(_value: T | AtomSource<T>, dependency?: AtomDependency<T>);
23
20
  derive<A>(deriveFn: (value: T, index: number) => A): ReadOnlyAtom<A>;
24
- subscribe(...params: Parameters<BehaviorSubject<T>["subscribe"]>): Subscription;
21
+ subscribe(observer: AtomObserver<T>): AtomSubscription;
25
22
  value(): T;
26
23
  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]>;
24
+ get<K extends SelectKey<T>>(key: K): SelectValue<T, K>;
25
+ select<K extends SelectKey<T>>(key: K): ReadOnlyAtom<SelectValue<T, K>>;
26
+ private _refresh;
27
+ private _retainDependency;
28
+ private _releaseDependency;
29
+ /** @internal */
30
+ _next(value: T): void;
31
+ /** @internal */
32
+ _subscribe(observer: AtomObserver<T>, options?: {
33
+ emitImmediately?: boolean;
34
+ }): AtomSubscription;
35
+ /** @internal */
36
+ _addSubscription(subscription: AtomSubscription | (() => void) | void): AtomSubscription;
29
37
  }
30
38
  export declare class BaseAtom<T> extends ReadOnlyAtom<T> {
31
39
  next(nextVal: T): void;
32
- set(nextKey: keyof T, nextValue: T[keyof T]): void;
40
+ set<K extends SelectKey<T>>(nextKey: K, nextValue: NonNullable<T>[K]): void;
33
41
  }
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]>;
42
+ export declare class NullableBaseAtom<T> extends BaseAtom<T | null | undefined> {
43
+ constructor(_value?: T | null | undefined | AtomSource<T | null | undefined>);
38
44
  next(nextVal: T | null | undefined): void;
39
45
  reset(): void;
40
46
  }
41
47
  export declare class ArrayAtom<T> extends BaseAtom<T[]> {
42
- constructor(initialValue?: T[]);
48
+ constructor(initialValue?: T[] | AtomSource<T[]>);
43
49
  push(nextVal: T): void;
44
50
  }
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>;
51
+ export declare function Atom<T>(value: T | AtomSource<T>, readOnly: true): ReadOnlyAtom<T>;
52
+ export declare function Atom<T extends any[]>(value: AtomSource<T>): ArrayAtom<T[number]>;
53
+ export declare function Atom<T>(value: AtomSource<T>): BaseAtom<T>;
58
54
  export declare function Atom<T extends any[]>(value?: T): ArrayAtom<T[number]>;
59
55
  export declare function Atom<T extends {
60
56
  [key: string]: T[keyof T];
@@ -64,8 +60,9 @@ export declare function Atom<T extends {
64
60
  }>(value?: T): NullableBaseAtom<T>;
65
61
  export declare function Atom<T>(value: T): BaseAtom<T>;
66
62
  export declare function Atom<T>(value?: T): NullableBaseAtom<T>;
67
- export declare function Atom<T>(value: T, readOnly?: boolean): ReadOnlyAtom<T>;
63
+ export declare function Atom<T>(value: T | AtomSource<T>, readOnly?: boolean): ReadOnlyAtom<T> | BaseAtom<T>;
68
64
  export declare namespace Atom {
69
- var combine: <A extends readonly unknown[]>(...atoms_0: AtomTuple<A>) => ReadOnlyAtom<A>;
65
+ var combine: <A extends readonly unknown[]>(...atoms: AtomTuple<A>) => ReadOnlyAtom<A>;
70
66
  }
67
+ export {};
71
68
  //# sourceMappingURL=Atom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Atom.d.ts","sourceRoot":"","sources":["../src/Atom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAMf,UAAU,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,MAAM,CAAC;AAGd,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;KACxB,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACnC,CAAC;AAEF,qBAAa,YAAY,CAAC,CAAC;IACzB,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAE/B,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAM;IAElC,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAQ;IAC7C,2BA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
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"}