@but212/atom-effect 0.19.0 → 0.20.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 +4 -3
- package/dist/atom-effect.min.js +1 -1
- package/dist/atom-effect.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -76
- package/dist/index.mjs +333 -384
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ export declare function atom<T>(initialValue: T, options?: AtomOptions): Writabl
|
|
|
27
27
|
export declare class AtomError extends Error {
|
|
28
28
|
cause: Error | null;
|
|
29
29
|
recoverable: boolean;
|
|
30
|
-
readonly timestamp: Date;
|
|
31
30
|
constructor(message: string, cause?: Error | null, recoverable?: boolean);
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -47,20 +46,6 @@ export declare interface AtomOptions {
|
|
|
47
46
|
*/
|
|
48
47
|
export declare function batch<T>(fn: () => T): T;
|
|
49
48
|
|
|
50
|
-
/**
|
|
51
|
-
* Nominal type brand.
|
|
52
|
-
*/
|
|
53
|
-
export declare type Branded<T, Brand> = T & {
|
|
54
|
-
readonly __brand: Brand;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Computation context.
|
|
59
|
-
*/
|
|
60
|
-
export declare interface ComputationContext {
|
|
61
|
-
links: DependencyLink[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
49
|
/**
|
|
65
50
|
* Creates a computed value.
|
|
66
51
|
* @param fn - Computation function
|
|
@@ -143,8 +128,6 @@ export declare interface Dependency {
|
|
|
143
128
|
flags: number;
|
|
144
129
|
/** Last validated epoch. */
|
|
145
130
|
_lastSeenEpoch: number;
|
|
146
|
-
/** Temporary unsubscribe. */
|
|
147
|
-
_tempUnsub?: (() => void) | undefined;
|
|
148
131
|
/** Last modified epoch. */
|
|
149
132
|
_modifiedAtEpoch?: number;
|
|
150
133
|
/**
|
|
@@ -158,29 +141,10 @@ export declare interface Dependency {
|
|
|
158
141
|
value?: unknown;
|
|
159
142
|
}
|
|
160
143
|
|
|
161
|
-
/**
|
|
162
|
-
* Graph entry.
|
|
163
|
-
*/
|
|
164
|
-
export declare interface DependencyEntry<T extends object = Dependency> {
|
|
165
|
-
/** Dependency reference. */
|
|
166
|
-
ref: WeakRef<T>;
|
|
167
|
-
unsubscribe: () => void;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
144
|
/**
|
|
171
145
|
* Dependency ID.
|
|
172
146
|
*/
|
|
173
|
-
export declare type DependencyId =
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Dependency graph edge.
|
|
177
|
-
*/
|
|
178
|
-
declare class DependencyLink {
|
|
179
|
-
node: Dependency;
|
|
180
|
-
version: number;
|
|
181
|
-
unsub: (() => void) | undefined;
|
|
182
|
-
constructor(node: Dependency, version: number, unsub?: (() => void) | undefined);
|
|
183
|
-
}
|
|
147
|
+
export declare type DependencyId = number;
|
|
184
148
|
|
|
185
149
|
/**
|
|
186
150
|
* Creates and starts an effect.
|
|
@@ -196,11 +160,6 @@ export declare class EffectError extends AtomError {
|
|
|
196
160
|
constructor(message: string, cause?: Error | null);
|
|
197
161
|
}
|
|
198
162
|
|
|
199
|
-
export declare interface EffectExecutionContext {
|
|
200
|
-
prevLinks: DependencyLink[];
|
|
201
|
-
nextLinks: DependencyLink[];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
163
|
/**
|
|
205
164
|
* Effect return type.
|
|
206
165
|
*/
|
|
@@ -221,16 +180,6 @@ export declare interface EffectOptions {
|
|
|
221
180
|
onError?: (error: unknown) => void;
|
|
222
181
|
}
|
|
223
182
|
|
|
224
|
-
/**
|
|
225
|
-
* Scheduler atom interface.
|
|
226
|
-
*/
|
|
227
|
-
export declare interface IAtom {
|
|
228
|
-
readonly id: number;
|
|
229
|
-
version: number;
|
|
230
|
-
_internalNotifySubscribers(): void;
|
|
231
|
-
recompute?(): void;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
183
|
/**
|
|
235
184
|
* Readonly atom check.
|
|
236
185
|
*
|
|
@@ -238,11 +187,6 @@ export declare interface IAtom {
|
|
|
238
187
|
*/
|
|
239
188
|
export declare function isAtom(obj: unknown): obj is ReadonlyAtom;
|
|
240
189
|
|
|
241
|
-
export declare interface IScheduler<T> {
|
|
242
|
-
markDirty(atom: T): void;
|
|
243
|
-
scheduleNotify(atom: T): void;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
190
|
/**
|
|
247
191
|
* Computed atom check.
|
|
248
192
|
*/
|
|
@@ -262,13 +206,6 @@ export declare const POOL_CONFIG: {
|
|
|
262
206
|
readonly ENABLE_STATS: false;
|
|
263
207
|
};
|
|
264
208
|
|
|
265
|
-
/**
|
|
266
|
-
* Poolable interface.
|
|
267
|
-
*/
|
|
268
|
-
export declare interface Poolable {
|
|
269
|
-
reset(): void;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
209
|
export declare interface PoolStats {
|
|
273
210
|
acquired: number;
|
|
274
211
|
released: number;
|
|
@@ -292,7 +229,7 @@ export declare interface ReadonlyAtom<T = unknown> {
|
|
|
292
229
|
* @param listener - Function called when value changes.
|
|
293
230
|
* @returns Unsubscribe function.
|
|
294
231
|
*/
|
|
295
|
-
subscribe(listener: (newValue?: T, oldValue?: T) => void): () => void;
|
|
232
|
+
subscribe(listener: ((newValue?: T, oldValue?: T) => void) | Subscriber): () => void;
|
|
296
233
|
/**
|
|
297
234
|
* Non-reactive read.
|
|
298
235
|
*/
|
|
@@ -302,7 +239,7 @@ export declare interface ReadonlyAtom<T = unknown> {
|
|
|
302
239
|
/**
|
|
303
240
|
* Scheduler implementation.
|
|
304
241
|
*/
|
|
305
|
-
|
|
242
|
+
declare class Scheduler {
|
|
306
243
|
/** Queue buffer */
|
|
307
244
|
_queueBuffer: [SchedulerJob[], SchedulerJob[]];
|
|
308
245
|
_bufferIndex: number;
|
|
@@ -319,9 +256,13 @@ export declare const scheduler: {
|
|
|
319
256
|
_batchQueueSize: number;
|
|
320
257
|
/** Config */
|
|
321
258
|
_maxFlushIterations: number;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
259
|
+
/** Overflow callback */
|
|
260
|
+
onOverflow: ((droppedCount: number) => void) | null;
|
|
261
|
+
/** Bound run loop for microtask */
|
|
262
|
+
private readonly _boundRunLoop;
|
|
263
|
+
get phase(): SchedulerPhase;
|
|
264
|
+
get queueSize(): number;
|
|
265
|
+
get isBatching(): boolean;
|
|
325
266
|
/**
|
|
326
267
|
* Schedules job.
|
|
327
268
|
*/
|
|
@@ -333,18 +274,18 @@ export declare const scheduler: {
|
|
|
333
274
|
/**
|
|
334
275
|
* Scheduler loop.
|
|
335
276
|
*/
|
|
336
|
-
_runLoop
|
|
277
|
+
private _runLoop;
|
|
337
278
|
_flushSync(): void;
|
|
338
279
|
_mergeBatchQueue(): void;
|
|
339
280
|
_drainQueue(): void;
|
|
340
281
|
_processQueue(): void;
|
|
341
|
-
|
|
342
|
-
onOverflow: ((droppedCount: number) => void) | null;
|
|
343
|
-
_handleFlushOverflow(): void;
|
|
282
|
+
private _handleFlushOverflow;
|
|
344
283
|
startBatch(): void;
|
|
345
284
|
endBatch(): void;
|
|
346
285
|
setMaxFlushIterations(max: number): void;
|
|
347
|
-
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export declare const scheduler: Scheduler;
|
|
348
289
|
|
|
349
290
|
/**
|
|
350
291
|
* Scheduler configuration.
|
|
@@ -380,8 +321,6 @@ export declare interface Subscriber {
|
|
|
380
321
|
execute(): void;
|
|
381
322
|
}
|
|
382
323
|
|
|
383
|
-
export declare type TransformFunction<T, U> = (value: T) => U;
|
|
384
|
-
|
|
385
324
|
/**
|
|
386
325
|
* Untracked execution.
|
|
387
326
|
*
|