atomirx 0.0.7 → 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 +198 -2234
- package/bin/cli.js +90 -0
- package/dist/core/derived.d.ts +2 -2
- package/dist/core/effect.d.ts +3 -2
- package/dist/core/onCreateHook.d.ts +15 -2
- package/dist/core/onErrorHook.d.ts +4 -1
- package/dist/core/pool.d.ts +78 -0
- package/dist/core/pool.test.d.ts +1 -0
- package/dist/core/select-boolean.test.d.ts +1 -0
- package/dist/core/select-pool.test.d.ts +1 -0
- package/dist/core/select.d.ts +278 -86
- package/dist/core/types.d.ts +233 -1
- package/dist/core/withAbort.d.ts +95 -0
- package/dist/core/withReady.d.ts +3 -3
- package/dist/devtools/constants.d.ts +41 -0
- package/dist/devtools/index.cjs +1 -0
- package/dist/devtools/index.d.ts +29 -0
- package/dist/devtools/index.js +429 -0
- package/dist/devtools/registry.d.ts +98 -0
- package/dist/devtools/registry.test.d.ts +1 -0
- package/dist/devtools/setup.d.ts +61 -0
- package/dist/devtools/types.d.ts +311 -0
- package/dist/index-BZEnfIcB.cjs +1 -0
- package/dist/index-BbPZhsDl.js +1653 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -14
- package/dist/onDispatchHook-C8yLzr-o.cjs +1 -0
- package/dist/onDispatchHook-SKbiIUaJ.js +5 -0
- package/dist/onErrorHook-BGGy3tqK.js +38 -0
- package/dist/onErrorHook-DHBASmYw.cjs +1 -0
- package/dist/react/index.cjs +1 -30
- package/dist/react/index.js +206 -791
- package/dist/react/onDispatchHook.d.ts +106 -0
- package/dist/react/useAction.d.ts +4 -1
- package/dist/react-devtools/DevToolsPanel.d.ts +93 -0
- package/dist/react-devtools/EntityDetails.d.ts +10 -0
- package/dist/react-devtools/EntityList.d.ts +15 -0
- package/dist/react-devtools/LogList.d.ts +12 -0
- package/dist/react-devtools/hooks.d.ts +50 -0
- package/dist/react-devtools/index.cjs +1 -0
- package/dist/react-devtools/index.d.ts +31 -0
- package/dist/react-devtools/index.js +1589 -0
- package/dist/react-devtools/styles.d.ts +148 -0
- package/package.json +26 -2
- package/skills/atomirx/SKILL.md +456 -0
- package/skills/atomirx/references/async-patterns.md +188 -0
- package/skills/atomirx/references/atom-patterns.md +238 -0
- package/skills/atomirx/references/deferred-loading.md +191 -0
- package/skills/atomirx/references/derived-patterns.md +428 -0
- package/skills/atomirx/references/effect-patterns.md +426 -0
- package/skills/atomirx/references/error-handling.md +140 -0
- package/skills/atomirx/references/hooks.md +322 -0
- package/skills/atomirx/references/pool-patterns.md +229 -0
- package/skills/atomirx/references/react-integration.md +411 -0
- package/skills/atomirx/references/rules.md +407 -0
- package/skills/atomirx/references/select-context.md +309 -0
- package/skills/atomirx/references/service-template.md +172 -0
- package/skills/atomirx/references/store-template.md +205 -0
- package/skills/atomirx/references/testing-patterns.md +431 -0
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -1440
- package/coverage/coverage-final.json +0 -14
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/coverage/src/core/atom.ts.html +0 -889
- package/coverage/src/core/batch.ts.html +0 -223
- package/coverage/src/core/define.ts.html +0 -805
- package/coverage/src/core/emitter.ts.html +0 -919
- package/coverage/src/core/equality.ts.html +0 -631
- package/coverage/src/core/hook.ts.html +0 -460
- package/coverage/src/core/index.html +0 -281
- package/coverage/src/core/isAtom.ts.html +0 -100
- package/coverage/src/core/isPromiseLike.ts.html +0 -133
- package/coverage/src/core/onCreateHook.ts.html +0 -138
- package/coverage/src/core/scheduleNotifyHook.ts.html +0 -94
- package/coverage/src/core/types.ts.html +0 -523
- package/coverage/src/core/withUse.ts.html +0 -253
- package/coverage/src/index.html +0 -116
- package/coverage/src/index.ts.html +0 -106
- package/dist/index-CBVj1kSj.js +0 -1350
- package/dist/index-Cxk9v0um.cjs +0 -1
- package/scripts/publish.js +0 -198
- package/src/core/atom.test.ts +0 -633
- package/src/core/atom.ts +0 -311
- package/src/core/atomState.test.ts +0 -342
- package/src/core/atomState.ts +0 -256
- package/src/core/batch.test.ts +0 -257
- package/src/core/batch.ts +0 -172
- package/src/core/define.test.ts +0 -343
- package/src/core/define.ts +0 -243
- package/src/core/derived.test.ts +0 -1215
- package/src/core/derived.ts +0 -450
- package/src/core/effect.test.ts +0 -802
- package/src/core/effect.ts +0 -188
- package/src/core/emitter.test.ts +0 -364
- package/src/core/emitter.ts +0 -392
- package/src/core/equality.test.ts +0 -392
- package/src/core/equality.ts +0 -182
- package/src/core/getAtomState.ts +0 -69
- package/src/core/hook.test.ts +0 -227
- package/src/core/hook.ts +0 -177
- package/src/core/isAtom.ts +0 -27
- package/src/core/isPromiseLike.test.ts +0 -72
- package/src/core/isPromiseLike.ts +0 -16
- package/src/core/onCreateHook.ts +0 -107
- package/src/core/onErrorHook.test.ts +0 -350
- package/src/core/onErrorHook.ts +0 -52
- package/src/core/promiseCache.test.ts +0 -241
- package/src/core/promiseCache.ts +0 -284
- package/src/core/scheduleNotifyHook.ts +0 -53
- package/src/core/select.ts +0 -729
- package/src/core/selector.test.ts +0 -799
- package/src/core/types.ts +0 -389
- package/src/core/withReady.test.ts +0 -534
- package/src/core/withReady.ts +0 -191
- package/src/core/withUse.test.ts +0 -249
- package/src/core/withUse.ts +0 -56
- package/src/index.test.ts +0 -80
- package/src/index.ts +0 -65
- package/src/react/index.ts +0 -21
- package/src/react/rx.test.tsx +0 -571
- package/src/react/rx.tsx +0 -531
- package/src/react/strictModeTest.tsx +0 -71
- package/src/react/useAction.test.ts +0 -987
- package/src/react/useAction.ts +0 -607
- package/src/react/useSelector.test.ts +0 -182
- package/src/react/useSelector.ts +0 -292
- package/src/react/useStable.test.ts +0 -553
- package/src/react/useStable.ts +0 -288
- package/tsconfig.json +0 -9
- package/v2.md +0 -725
- package/vite.config.ts +0 -39
package/src/core/types.ts
DELETED
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic function type that accepts any arguments and returns any value.
|
|
3
|
-
* Used internally for type-safe function handling.
|
|
4
|
-
*/
|
|
5
|
-
export type AnyFunc = (...args: any[]) => any;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Unique symbol used to identify atom instances.
|
|
9
|
-
* Uses Symbol.for() to ensure the same symbol across different module instances.
|
|
10
|
-
*/
|
|
11
|
-
export const SYMBOL_ATOM = Symbol.for("atomirx.atom");
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Symbol to identify derived atoms.
|
|
15
|
-
*/
|
|
16
|
-
export const SYMBOL_DERIVED = Symbol.for("atomirx.derived");
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Interface for objects that support the `.use()` plugin pattern.
|
|
20
|
-
*
|
|
21
|
-
* The `.use()` method enables chainable transformations via plugins.
|
|
22
|
-
* Return type behavior:
|
|
23
|
-
* - `void` → returns original source (side-effect only)
|
|
24
|
-
* - Object with `.use` → returns as-is (already pipeable)
|
|
25
|
-
* - Object without `.use` → wraps with Pipeable
|
|
26
|
-
* - Primitive → returns directly (not chainable)
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const enhanced = atom(0)
|
|
31
|
-
* .use(source => ({ ...source, double: () => source.get() * 2 }))
|
|
32
|
-
* .use(source => ({ ...source, triple: () => source.get() * 3 }));
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export interface Pipeable {
|
|
36
|
-
use<TNew = void>(
|
|
37
|
-
plugin: (source: this) => TNew
|
|
38
|
-
): void extends TNew
|
|
39
|
-
? this
|
|
40
|
-
: TNew extends object
|
|
41
|
-
? TNew extends { use: any }
|
|
42
|
-
? TNew
|
|
43
|
-
: Pipeable & TNew
|
|
44
|
-
: TNew;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Optional metadata for atoms.
|
|
49
|
-
*/
|
|
50
|
-
export interface AtomMeta extends AtomirxMeta {
|
|
51
|
-
key?: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Base interface for all atoms.
|
|
56
|
-
* Represents a reactive value container with subscription capability.
|
|
57
|
-
*
|
|
58
|
-
* @template T - The type of value stored in the atom
|
|
59
|
-
*/
|
|
60
|
-
export interface Atom<T> {
|
|
61
|
-
/** Symbol marker to identify atom instances */
|
|
62
|
-
readonly [SYMBOL_ATOM]: true;
|
|
63
|
-
|
|
64
|
-
/** Optional metadata for the atom */
|
|
65
|
-
readonly meta?: AtomMeta;
|
|
66
|
-
|
|
67
|
-
/** Get the current value */
|
|
68
|
-
get(): T;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Subscribe to value changes.
|
|
72
|
-
* @param listener - Callback invoked when value changes
|
|
73
|
-
* @returns Unsubscribe function
|
|
74
|
-
*/
|
|
75
|
-
on(listener: VoidFunction): VoidFunction;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* A mutable atom that can be updated via `set()` and reset to initial state.
|
|
80
|
-
*
|
|
81
|
-
* MutableAtom is a raw storage container. It stores values as-is, including Promises.
|
|
82
|
-
* Unlike DerivedAtom, it does not automatically unwrap or track Promise states.
|
|
83
|
-
*
|
|
84
|
-
* @template T - The type of value stored in the atom
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* // Sync value
|
|
89
|
-
* const count = atom(0);
|
|
90
|
-
* count.set(5); // Direct value
|
|
91
|
-
* count.set(n => n + 1); // Reducer function
|
|
92
|
-
* count.reset(); // Back to 0
|
|
93
|
-
*
|
|
94
|
-
* // Async value (stores Promise as-is)
|
|
95
|
-
* const posts = atom(fetchPosts());
|
|
96
|
-
* posts.get(); // Promise<Post[]>
|
|
97
|
-
* posts.set(fetchPosts()); // Store new Promise
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
export interface MutableAtom<T> extends Atom<T>, Pipeable {
|
|
101
|
-
/** Reset atom to its initial state (also clears dirty flag) */
|
|
102
|
-
reset(): void;
|
|
103
|
-
/**
|
|
104
|
-
* Update the atom's value.
|
|
105
|
-
*
|
|
106
|
-
* @param value - New value or reducer function (prev) => newValue
|
|
107
|
-
*/
|
|
108
|
-
set(value: T | ((prev: T) => T)): void;
|
|
109
|
-
/**
|
|
110
|
-
* Returns `true` if the value has changed since initialization or last `reset()`.
|
|
111
|
-
*
|
|
112
|
-
* Useful for:
|
|
113
|
-
* - Tracking unsaved changes
|
|
114
|
-
* - Enabling/disabling save buttons
|
|
115
|
-
* - Detecting form modifications
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```ts
|
|
119
|
-
* const form$ = atom({ name: "", email: "" });
|
|
120
|
-
*
|
|
121
|
-
* form$.dirty(); // false - just initialized
|
|
122
|
-
*
|
|
123
|
-
* form$.set({ name: "John", email: "" });
|
|
124
|
-
* form$.dirty(); // true - value changed
|
|
125
|
-
*
|
|
126
|
-
* form$.reset();
|
|
127
|
-
* form$.dirty(); // false - reset clears dirty flag
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
dirty(): boolean;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* A derived (computed) atom that always returns Promise<T> for its value.
|
|
135
|
-
*
|
|
136
|
-
* DerivedAtom computes its value from other atoms. The computation is
|
|
137
|
-
* re-run whenever dependencies change. The `.get()` always returns a Promise,
|
|
138
|
-
* even for synchronous computations.
|
|
139
|
-
*
|
|
140
|
-
* @template T - The resolved type of the computed value
|
|
141
|
-
* @template F - Whether fallback is provided (affects staleValue type)
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* ```ts
|
|
145
|
-
* // Without fallback
|
|
146
|
-
* const double$ = derived(({ read }) => read(count$) * 2);
|
|
147
|
-
* await double$.get(); // number
|
|
148
|
-
* double$.staleValue; // number | undefined
|
|
149
|
-
* double$.state(); // { status: "ready", value: 10 }
|
|
150
|
-
*
|
|
151
|
-
* // With fallback - during loading
|
|
152
|
-
* const double$ = derived(({ read }) => read(count$) * 2, { fallback: 0 });
|
|
153
|
-
* double$.staleValue; // number (guaranteed)
|
|
154
|
-
* double$.state(); // { status: "loading", promise } during loading
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
export interface DerivedAtom<T, F extends boolean = false> extends Atom<
|
|
158
|
-
Promise<T>
|
|
159
|
-
> {
|
|
160
|
-
/** Symbol marker to identify derived atom instances */
|
|
161
|
-
readonly [SYMBOL_DERIVED]: true;
|
|
162
|
-
/** Re-run the computation */
|
|
163
|
-
refresh(): void;
|
|
164
|
-
/**
|
|
165
|
-
* Get the current state of the derived atom.
|
|
166
|
-
* Returns a discriminated union with status, value/error, and stale flag.
|
|
167
|
-
*/
|
|
168
|
-
state(): AtomState<T>;
|
|
169
|
-
/**
|
|
170
|
-
* The stale value - fallback or last resolved value.
|
|
171
|
-
* - Without fallback: T | undefined
|
|
172
|
-
* - With fallback: T (guaranteed)
|
|
173
|
-
*/
|
|
174
|
-
readonly staleValue: F extends true ? T : T | undefined;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Union type for any atom (mutable or derived).
|
|
179
|
-
*/
|
|
180
|
-
export type AnyAtom<T> = MutableAtom<T> | DerivedAtom<T, boolean>;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Extract the value type from an atom.
|
|
184
|
-
* For DerivedAtom, returns the awaited type.
|
|
185
|
-
*/
|
|
186
|
-
export type AtomValue<A> =
|
|
187
|
-
A extends DerivedAtom<infer V, boolean>
|
|
188
|
-
? V
|
|
189
|
-
: A extends Atom<infer V>
|
|
190
|
-
? Awaited<V>
|
|
191
|
-
: never;
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Represents the state of an atom as a discriminated union.
|
|
195
|
-
*
|
|
196
|
-
* Uses intuitive state terms:
|
|
197
|
-
* - `ready` - Value is available
|
|
198
|
-
* - `error` - Computation failed
|
|
199
|
-
* - `loading` - Waiting for async value
|
|
200
|
-
*
|
|
201
|
-
* @template T - The type of the atom's value
|
|
202
|
-
*/
|
|
203
|
-
export type AtomState<T> =
|
|
204
|
-
| { status: "ready"; value: T; error?: undefined; promise?: undefined }
|
|
205
|
-
| { status: "error"; error: unknown; value?: undefined; promise?: undefined }
|
|
206
|
-
| {
|
|
207
|
-
status: "loading";
|
|
208
|
-
promise: Promise<T>;
|
|
209
|
-
value?: undefined;
|
|
210
|
-
error?: undefined;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Result type for SelectContext.state() - simplified AtomState without promise.
|
|
215
|
-
*
|
|
216
|
-
* All properties (`status`, `value`, `error`) are always present:
|
|
217
|
-
* - `value` is `T` when ready, `undefined` otherwise
|
|
218
|
-
* - `error` is the error when errored, `undefined` otherwise
|
|
219
|
-
*
|
|
220
|
-
* This enables easy destructuring without type narrowing:
|
|
221
|
-
* ```ts
|
|
222
|
-
* const { status, value, error } = state(atom$);
|
|
223
|
-
* ```
|
|
224
|
-
*
|
|
225
|
-
* Equality comparisons work correctly (no promise reference issues).
|
|
226
|
-
*/
|
|
227
|
-
export type SelectStateResult<T> =
|
|
228
|
-
| { status: "ready"; value: T; error: undefined }
|
|
229
|
-
| { status: "error"; value: undefined; error: unknown }
|
|
230
|
-
| { status: "loading"; value: undefined; error: undefined };
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Result type for race() and any() - includes winning key.
|
|
234
|
-
*
|
|
235
|
-
* @template K - The key type (string literal union)
|
|
236
|
-
* @template V - The value type
|
|
237
|
-
*/
|
|
238
|
-
export type KeyedResult<K extends string, V> = {
|
|
239
|
-
/** The key that won the race/any */
|
|
240
|
-
key: K;
|
|
241
|
-
/** The resolved value */
|
|
242
|
-
value: V;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
export type AtomPlugin = <T extends Atom<any>>(atom: T) => T | void;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Result type for settled operations.
|
|
249
|
-
*/
|
|
250
|
-
export type SettledResult<T> =
|
|
251
|
-
| { status: "ready"; value: T }
|
|
252
|
-
| { status: "error"; error: unknown };
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Configuration options for creating a mutable atom.
|
|
256
|
-
*
|
|
257
|
-
* @template T - The type of value stored in the atom
|
|
258
|
-
*/
|
|
259
|
-
export interface AtomOptions<T> {
|
|
260
|
-
/** Optional metadata for the atom */
|
|
261
|
-
meta?: MutableAtomMeta;
|
|
262
|
-
/** Equality strategy for change detection (default: "strict") */
|
|
263
|
-
equals?: Equality<T>;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export interface MutableAtomMeta extends AtomMeta {}
|
|
267
|
-
|
|
268
|
-
export interface DerivedAtomMeta extends AtomMeta {}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Configuration options for creating a derived atom.
|
|
272
|
-
*
|
|
273
|
-
* @template T - The type of the derived value
|
|
274
|
-
*/
|
|
275
|
-
export interface DerivedOptions<T> {
|
|
276
|
-
/** Optional metadata for the atom */
|
|
277
|
-
meta?: DerivedAtomMeta;
|
|
278
|
-
/** Equality strategy for change detection (default: "strict") */
|
|
279
|
-
equals?: Equality<T>;
|
|
280
|
-
/**
|
|
281
|
-
* Callback invoked when the derived computation throws an error.
|
|
282
|
-
* This is called for actual errors, NOT for Promise throws (Suspense).
|
|
283
|
-
*
|
|
284
|
-
* @param error - The error thrown during computation
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* ```ts
|
|
288
|
-
* const data$ = derived(
|
|
289
|
-
* ({ read }) => {
|
|
290
|
-
* const raw = read(source$);
|
|
291
|
-
* return JSON.parse(raw); // May throw SyntaxError
|
|
292
|
-
* },
|
|
293
|
-
* {
|
|
294
|
-
* onError: (error) => {
|
|
295
|
-
* console.error('Derived computation failed:', error);
|
|
296
|
-
* reportToSentry(error);
|
|
297
|
-
* }
|
|
298
|
-
* }
|
|
299
|
-
* );
|
|
300
|
-
* ```
|
|
301
|
-
*/
|
|
302
|
-
onError?: (error: unknown) => void;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Configuration options for effects.
|
|
307
|
-
*/
|
|
308
|
-
export interface EffectOptions {
|
|
309
|
-
meta?: EffectMeta;
|
|
310
|
-
/**
|
|
311
|
-
* Callback invoked when the effect computation throws an error.
|
|
312
|
-
* This is called for actual errors, NOT for Promise throws (Suspense).
|
|
313
|
-
*
|
|
314
|
-
* @param error - The error thrown during effect execution
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
* ```ts
|
|
318
|
-
* effect(
|
|
319
|
-
* ({ read }) => {
|
|
320
|
-
* const data = read(source$);
|
|
321
|
-
* riskyOperation(data); // May throw
|
|
322
|
-
* },
|
|
323
|
-
* {
|
|
324
|
-
* onError: (error) => {
|
|
325
|
-
* console.error('Effect failed:', error);
|
|
326
|
-
* showErrorNotification(error);
|
|
327
|
-
* }
|
|
328
|
-
* }
|
|
329
|
-
* );
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
332
|
-
onError?: (error: unknown) => void;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
export interface AtomirxMeta {}
|
|
336
|
-
|
|
337
|
-
export interface EffectMeta extends AtomirxMeta {
|
|
338
|
-
key?: string;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* A function that returns a value when called.
|
|
343
|
-
* Used for lazy evaluation in derived atoms.
|
|
344
|
-
*
|
|
345
|
-
* @template T - The type of value returned
|
|
346
|
-
*/
|
|
347
|
-
export type Getter<T> = () => T;
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Built-in equality strategy names.
|
|
351
|
-
*
|
|
352
|
-
* Used with atoms to control when subscribers are notified:
|
|
353
|
-
* - `"strict"` - Object.is (default, fastest)
|
|
354
|
-
* - `"shallow"` - Compare object keys/array items with Object.is
|
|
355
|
-
* - `"shallow2"` - 2 levels deep
|
|
356
|
-
* - `"shallow3"` - 3 levels deep
|
|
357
|
-
* - `"deep"` - Full recursive comparison (slowest)
|
|
358
|
-
*/
|
|
359
|
-
export type EqualityShorthand =
|
|
360
|
-
| "strict"
|
|
361
|
-
| "shallow"
|
|
362
|
-
| "shallow2"
|
|
363
|
-
| "shallow3"
|
|
364
|
-
| "deep";
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Equality strategy for change detection.
|
|
368
|
-
*
|
|
369
|
-
* Can be a shorthand string or custom comparison function.
|
|
370
|
-
* Used by atoms to determine if value has "changed" -
|
|
371
|
-
* if equal, subscribers won't be notified.
|
|
372
|
-
*
|
|
373
|
-
* @template T - Type of values being compared
|
|
374
|
-
*/
|
|
375
|
-
export type Equality<T = unknown> =
|
|
376
|
-
| EqualityShorthand
|
|
377
|
-
| ((a: T, b: T) => boolean);
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Prettify a type by adding all properties to the type.
|
|
381
|
-
* @template T - The type to prettify
|
|
382
|
-
*/
|
|
383
|
-
export type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
384
|
-
|
|
385
|
-
export interface ModuleMeta {}
|
|
386
|
-
|
|
387
|
-
export type Listener<T> = (value: T) => void;
|
|
388
|
-
|
|
389
|
-
export type SingleOrMultipleListeners<T> = Listener<T> | Listener<T>[];
|