@estjs/signals 0.0.15-beta.9 → 0.0.16-beta.1
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/dist/signals.cjs.js +3 -3
- package/dist/signals.cjs.js.map +1 -1
- package/dist/signals.d.cts +170 -182
- package/dist/signals.d.ts +170 -182
- package/dist/signals.dev.cjs.js +465 -340
- package/dist/signals.dev.esm.js +466 -341
- package/dist/signals.esm.js +3 -3
- package/dist/signals.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/signals.d.ts
CHANGED
|
@@ -215,21 +215,29 @@ interface ReactiveNode {
|
|
|
215
215
|
*/
|
|
216
216
|
onTrack?: (event: DebuggerEvent) => void;
|
|
217
217
|
/**
|
|
218
|
-
* Optional debugging hook called when reactive changes are triggered
|
|
218
|
+
* Optional debugging hook called when reactive changes are triggered.
|
|
219
219
|
*/
|
|
220
220
|
onTrigger?: (event: DebuggerEvent) => void;
|
|
221
|
+
/**
|
|
222
|
+
* When true, this node is a pure dependency (leaf); it should not receive
|
|
223
|
+
* a DIRTY flag during invalidation because it has no derived value to recompute.
|
|
224
|
+
*/
|
|
225
|
+
isDep?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Deduplication stamp used during batch notification.
|
|
228
|
+
* Prevents the same effect from being pushed into the pending queue twice.
|
|
229
|
+
*/
|
|
230
|
+
_triggerVersion?: number;
|
|
221
231
|
}
|
|
222
232
|
/**
|
|
223
|
-
* Execute function with tracking disabled
|
|
224
|
-
*
|
|
225
|
-
* During function execution, accessing Signals won't establish dependencies.
|
|
233
|
+
* Execute function with tracking disabled.
|
|
226
234
|
*
|
|
227
|
-
* @param fn - The function to execute
|
|
228
|
-
* @returns The function's return value
|
|
235
|
+
* @param fn - The function to execute.
|
|
236
|
+
* @returns {T} The function's return value.
|
|
229
237
|
*/
|
|
230
238
|
declare function untrack<T>(fn: () => T): T;
|
|
231
239
|
/**
|
|
232
|
-
* Trigger updates for subscribers of a reactive object property
|
|
240
|
+
* Trigger updates for subscribers of a reactive object property.
|
|
233
241
|
*
|
|
234
242
|
* This function notifies all subscribers (effects/computed) that depend on a specific
|
|
235
243
|
* property of a reactive object that the property has changed.
|
|
@@ -250,11 +258,11 @@ declare function untrack<T>(fn: () => T): T;
|
|
|
250
258
|
* - **CLEAR**: Collection cleared (affects iteration)
|
|
251
259
|
*
|
|
252
260
|
* ## Iteration Dependencies
|
|
253
|
-
|
|
254
|
-
* @param target - The reactive object that changed
|
|
255
|
-
* @param type - The type of operation: 'SET' | 'ADD' | 'DELETE' | 'CLEAR'
|
|
256
|
-
* @param key - The property key that changed (optional for CLEAR operations)
|
|
257
|
-
* @param newValue - The new value
|
|
261
|
+
*
|
|
262
|
+
* @param target - The reactive object that changed.
|
|
263
|
+
* @param type - The type of operation: 'SET' | 'ADD' | 'DELETE' | 'CLEAR'.
|
|
264
|
+
* @param key - The property key that changed (optional for CLEAR operations).
|
|
265
|
+
* @param newValue - The new value.
|
|
258
266
|
*
|
|
259
267
|
* @example
|
|
260
268
|
* ```typescript
|
|
@@ -276,6 +284,15 @@ declare function untrack<T>(fn: () => T): T;
|
|
|
276
284
|
* // trigger(state.items, 'ADD', '3', 4)
|
|
277
285
|
* ```
|
|
278
286
|
*/
|
|
287
|
+
/**
|
|
288
|
+
* Trigger updates for subscribers of a reactive object property.
|
|
289
|
+
*
|
|
290
|
+
* @param target - The reactive object that changed.
|
|
291
|
+
* @param type - The type of operation: 'SET' | 'ADD' | 'DELETE' | 'CLEAR'.
|
|
292
|
+
* @param key - The property key that changed (optional for CLEAR operations).
|
|
293
|
+
* @param newValue - The new value.
|
|
294
|
+
* @returns {void}
|
|
295
|
+
*/
|
|
279
296
|
declare function trigger(target: object, type: string, key?: string | symbol | (string | symbol)[], newValue?: unknown): void;
|
|
280
297
|
|
|
281
298
|
/**
|
|
@@ -337,9 +354,9 @@ type SignalType<T> = T extends Signal<infer V> ? V : never;
|
|
|
337
354
|
* Create a new signal with the given initial value.
|
|
338
355
|
* The signal will track all nested properties of object values.
|
|
339
356
|
*
|
|
340
|
-
* @template T - The type of value to store in the signal
|
|
341
|
-
* @param value - Initial value (defaults to undefined)
|
|
342
|
-
* @returns A new signal instance
|
|
357
|
+
* @template T - The type of value to store in the signal.
|
|
358
|
+
* @param value - Initial value (defaults to undefined).
|
|
359
|
+
* @returns A new signal instance.
|
|
343
360
|
*
|
|
344
361
|
* @example
|
|
345
362
|
* ```typescript
|
|
@@ -353,9 +370,9 @@ declare function signal<T>(value?: T): Signal<T>;
|
|
|
353
370
|
* Create a new shallow signal with the given initial value.
|
|
354
371
|
* Only the top-level properties of object values are reactive.
|
|
355
372
|
*
|
|
356
|
-
* @template T - The type of value to store in the signal
|
|
357
|
-
* @param value - Initial value (defaults to undefined)
|
|
358
|
-
* @returns A new shallow signal instance
|
|
373
|
+
* @template T - The type of value to store in the signal.
|
|
374
|
+
* @param value - Initial value (defaults to undefined).
|
|
375
|
+
* @returns A new shallow signal instance.
|
|
359
376
|
*
|
|
360
377
|
* @example
|
|
361
378
|
* ```typescript
|
|
@@ -367,9 +384,9 @@ declare function shallowSignal<T>(value?: T): Signal<T>;
|
|
|
367
384
|
/**
|
|
368
385
|
* Type guard to check if a value is a Signal instance.
|
|
369
386
|
*
|
|
370
|
-
* @template T - The type of value held by the signal
|
|
371
|
-
* @param value - The value to check
|
|
372
|
-
* @returns true if the value is a Signal instance
|
|
387
|
+
* @template T - The type of value held by the signal.
|
|
388
|
+
* @param value - The value to check.
|
|
389
|
+
* @returns true if the value is a Signal instance.
|
|
373
390
|
*/
|
|
374
391
|
declare function isSignal<T>(value: unknown): value is Signal<T>;
|
|
375
392
|
|
|
@@ -449,25 +466,30 @@ declare class ComputedImpl<T = any> implements Computed<T>, ReactiveNode {
|
|
|
449
466
|
readonly onTrigger?: (event: DebuggerEvent) => void;
|
|
450
467
|
private _value;
|
|
451
468
|
/**
|
|
452
|
-
* Create a Computed instance
|
|
469
|
+
* Create a Computed instance.
|
|
453
470
|
*
|
|
454
|
-
* @param getter - The computation function
|
|
455
|
-
* @param setter - Optional setter function
|
|
456
|
-
* @param onTrack - Optional debug callback for dependency tracking
|
|
457
|
-
* @param onTrigger - Optional debug callback for triggers
|
|
471
|
+
* @param getter - The computation function.
|
|
472
|
+
* @param setter - Optional setter function.
|
|
473
|
+
* @param onTrack - Optional debug callback for dependency tracking.
|
|
474
|
+
* @param onTrigger - Optional debug callback for triggers.
|
|
458
475
|
*/
|
|
459
476
|
constructor(getter: ComputedGetter<T>, setter?: ComputedSetter<T>, onTrack?: (event: DebuggerEvent) => void, onTrigger?: (event: DebuggerEvent) => void);
|
|
477
|
+
/**
|
|
478
|
+
* Returns the current value.
|
|
479
|
+
*
|
|
480
|
+
* @returns {T} The current value.
|
|
481
|
+
*/
|
|
460
482
|
get value(): T;
|
|
461
483
|
/**
|
|
462
|
-
* Set value (only effective when setter is provided)
|
|
484
|
+
* Set value (only effective when setter is provided).
|
|
463
485
|
*
|
|
464
|
-
* @param newValue - The new value
|
|
486
|
+
* @param newValue - The new value.
|
|
465
487
|
*/
|
|
466
488
|
set value(newValue: T);
|
|
467
489
|
/**
|
|
468
|
-
* Read value without tracking dependencies
|
|
490
|
+
* Read value without tracking dependencies.
|
|
469
491
|
*
|
|
470
|
-
* @returns
|
|
492
|
+
* @returns {T} The current value.
|
|
471
493
|
*/
|
|
472
494
|
peek(): T;
|
|
473
495
|
/**
|
|
@@ -483,19 +505,19 @@ declare class ComputedImpl<T = any> implements Computed<T>, ReactiveNode {
|
|
|
483
505
|
*/
|
|
484
506
|
private recompute;
|
|
485
507
|
/**
|
|
486
|
-
* Check if update is needed
|
|
508
|
+
* Check if update is needed.
|
|
487
509
|
*
|
|
488
510
|
* Internal use, called by reactive system.
|
|
489
511
|
*
|
|
490
|
-
* @returns
|
|
512
|
+
* @returns {boolean} True if value changed.
|
|
491
513
|
*/
|
|
492
514
|
shouldUpdate(): boolean;
|
|
493
515
|
}
|
|
494
516
|
/**
|
|
495
|
-
* Create a Computed value
|
|
517
|
+
* Create a Computed value.
|
|
496
518
|
*
|
|
497
|
-
* @param getterOrOptions - Computation function or configuration object
|
|
498
|
-
* @returns Computed instance
|
|
519
|
+
* @param getterOrOptions - Computation function or configuration object.
|
|
520
|
+
* @returns {ComputedImpl<T>} Computed instance.
|
|
499
521
|
*
|
|
500
522
|
* @example
|
|
501
523
|
* ```typescript
|
|
@@ -526,10 +548,11 @@ declare class ComputedImpl<T = any> implements Computed<T>, ReactiveNode {
|
|
|
526
548
|
*/
|
|
527
549
|
declare function computed<T>(getterOrOptions: ComputedGetter<T> | ComputedOptions<T>): ComputedImpl<T>;
|
|
528
550
|
/**
|
|
529
|
-
* Type guard - Check if value is Computed
|
|
551
|
+
* Type guard - Check if value is a Computed instance.
|
|
530
552
|
*
|
|
531
|
-
* @
|
|
532
|
-
* @
|
|
553
|
+
* @template T - The type of value held by the computed instance.
|
|
554
|
+
* @param value - The value to check.
|
|
555
|
+
* @returns {boolean} True if value is a Computed instance.
|
|
533
556
|
*/
|
|
534
557
|
declare function isComputed<T>(value: unknown): value is Computed<T>;
|
|
535
558
|
|
|
@@ -538,22 +561,22 @@ declare function isComputed<T>(value: unknown): value is Computed<T>;
|
|
|
538
561
|
* Recursively unwraps nested reactive objects and arrays.
|
|
539
562
|
*
|
|
540
563
|
* @param value - Reactive or signal value.
|
|
541
|
-
* @returns Raw value without any reactive wrapping.
|
|
564
|
+
* @returns {T} Raw value without any reactive wrapping.
|
|
542
565
|
*/
|
|
543
566
|
declare function toRaw<T>(value: T): T;
|
|
544
567
|
/**
|
|
545
568
|
* Check if the target object is reactive.
|
|
546
569
|
*
|
|
547
570
|
* @param target - The object to check.
|
|
548
|
-
* @returns True if the object is reactive, false otherwise.
|
|
571
|
+
* @returns {boolean} True if the object is reactive, false otherwise.
|
|
549
572
|
*/
|
|
550
573
|
declare function isReactive(target: unknown): boolean;
|
|
551
574
|
/**
|
|
552
575
|
* Create a reactive proxy for the given target object. If the object is already reactive, return directly.
|
|
553
576
|
*
|
|
554
|
-
* @template T - The type of the object to make reactive
|
|
555
|
-
* @param target - The object to make reactive
|
|
556
|
-
* @returns The reactive proxy of the target object
|
|
577
|
+
* @template T - The type of the object to make reactive.
|
|
578
|
+
* @param target - The object to make reactive.
|
|
579
|
+
* @returns {T} The reactive proxy of the target object.
|
|
557
580
|
*
|
|
558
581
|
* @example
|
|
559
582
|
* ```typescript
|
|
@@ -565,9 +588,9 @@ declare function reactive<T extends object>(target: T): T;
|
|
|
565
588
|
/**
|
|
566
589
|
* Create a shallow reactive proxy for the given object. Only root-level properties are reactive.
|
|
567
590
|
*
|
|
568
|
-
* @template T - The type of the object to make shallow reactive
|
|
569
|
-
* @param target - The object to make shallow reactive
|
|
570
|
-
* @returns The shallow reactive proxy of the object
|
|
591
|
+
* @template T - The type of the object to make shallow reactive.
|
|
592
|
+
* @param target - The object to make shallow reactive.
|
|
593
|
+
* @returns {T} The shallow reactive proxy of the object.
|
|
571
594
|
*
|
|
572
595
|
* @example
|
|
573
596
|
* ```typescript
|
|
@@ -580,7 +603,7 @@ declare function shallowReactive<T extends object>(target: T): T;
|
|
|
580
603
|
* Check if the target object is a shallow reactive proxy.
|
|
581
604
|
*
|
|
582
605
|
* @param value - The object to check.
|
|
583
|
-
* @returns True if the object is shallow reactive, false otherwise.
|
|
606
|
+
* @returns {boolean} True if the object is shallow reactive, false otherwise.
|
|
584
607
|
*/
|
|
585
608
|
declare function isShallow(value: unknown): boolean;
|
|
586
609
|
/**
|
|
@@ -588,6 +611,7 @@ declare function isShallow(value: unknown): boolean;
|
|
|
588
611
|
* If the given value is not an object, return the original value itself.
|
|
589
612
|
*
|
|
590
613
|
* @param value - The value that needs a reactive proxy created for it.
|
|
614
|
+
* @returns {T} The reactive proxy of the value, or the original value.
|
|
591
615
|
*/
|
|
592
616
|
declare const toReactive: <T extends unknown>(value: T) => T;
|
|
593
617
|
/**
|
|
@@ -614,29 +638,22 @@ type PreFlushCallback = () => void;
|
|
|
614
638
|
*/
|
|
615
639
|
type FlushTiming = 'pre' | 'post' | 'sync';
|
|
616
640
|
/**
|
|
617
|
-
* Schedules a function to be executed in the next microtask
|
|
618
|
-
*
|
|
619
|
-
* If no function is provided, returns a Promise that resolves in the next microtask.
|
|
620
|
-
* This is useful for waiting until the DOM is update or deferring execution.
|
|
641
|
+
* Schedules a function to be executed in the next microtask.
|
|
621
642
|
*
|
|
622
|
-
* @param fn - Optional function to execute
|
|
623
|
-
* @returns A Promise that resolves after the function execution
|
|
643
|
+
* @param fn - Optional function to execute.
|
|
644
|
+
* @returns A Promise that resolves after the function execution.
|
|
624
645
|
*/
|
|
625
646
|
declare function nextTick(fn?: () => void): Promise<void>;
|
|
626
647
|
/**
|
|
627
|
-
* Adds a job to the main queue and ensures it will be executed
|
|
648
|
+
* Adds a job to the main queue and ensures it will be executed.
|
|
628
649
|
*
|
|
629
|
-
*
|
|
630
|
-
* This is useful for batching updates and avoiding redundant work.
|
|
631
|
-
* @param job - The job to enqueue
|
|
650
|
+
* @param job - The job to enqueue.
|
|
632
651
|
*/
|
|
633
652
|
declare function queueJob(job: Job): void;
|
|
634
653
|
/**
|
|
635
|
-
* Adds a callback to be executed before the main queue processing
|
|
654
|
+
* Adds a callback to be executed before the main queue processing.
|
|
636
655
|
*
|
|
637
|
-
*
|
|
638
|
-
* such as computing derived values or preparing state.
|
|
639
|
-
* @param cb - The callback to execute before the main queue
|
|
656
|
+
* @param cb - The callback to execute before the main queue.
|
|
640
657
|
*/
|
|
641
658
|
declare function queuePreFlushCb(cb: PreFlushCallback): void;
|
|
642
659
|
|
|
@@ -748,82 +765,66 @@ declare class EffectImpl<T = any> implements ReactiveNode {
|
|
|
748
765
|
flag: ReactiveFlags;
|
|
749
766
|
private readonly [SignalFlags.IS_EFFECT];
|
|
750
767
|
readonly fn: EffectFunction<T>;
|
|
751
|
-
readonly
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
readonly flash?: 'sync' | 'pre' | 'post';
|
|
768
|
+
readonly options?: EffectOptions;
|
|
769
|
+
private _flushScheduler?;
|
|
770
|
+
onTrack?: (event: DebuggerEvent) => void;
|
|
771
|
+
onTrigger?: (event: DebuggerEvent) => void;
|
|
756
772
|
private _active;
|
|
757
773
|
/**
|
|
758
|
-
* Create an Effect instance
|
|
774
|
+
* Create an Effect instance.
|
|
759
775
|
*
|
|
760
|
-
* @param fn - The effect function
|
|
761
|
-
* @param options - Configuration options
|
|
776
|
+
* @param fn - The effect function.
|
|
777
|
+
* @param options - Configuration options.
|
|
762
778
|
*/
|
|
763
779
|
constructor(fn: EffectFunction<T>, options?: EffectOptions);
|
|
764
780
|
/**
|
|
765
|
-
* Check if the Effect is active
|
|
781
|
+
* Check if the Effect is active.
|
|
782
|
+
*
|
|
783
|
+
* @returns {boolean} True if the effect is active.
|
|
766
784
|
*/
|
|
767
785
|
get active(): boolean;
|
|
768
786
|
/**
|
|
769
|
-
* Check if the Effect is dirty (needs re-execution)
|
|
770
|
-
|
|
787
|
+
* Check if the Effect is dirty (needs re-execution).
|
|
788
|
+
*
|
|
789
|
+
* @returns {boolean} True if the effect is dirty.
|
|
771
790
|
*/
|
|
772
791
|
get dirty(): boolean;
|
|
773
792
|
/**
|
|
774
|
-
* Pause Effect execution
|
|
793
|
+
* Pause Effect execution.
|
|
775
794
|
*
|
|
776
795
|
* When an effect is paused:
|
|
777
|
-
* - It stops responding to dependency changes
|
|
778
|
-
* - Notifications are ignored (see notify method)
|
|
779
|
-
* - DIRTY and PENDING flags are still set when dependencies change
|
|
780
|
-
* - The effect remains active and maintains its dependency links
|
|
796
|
+
* - It stops responding to dependency changes.
|
|
797
|
+
* - Notifications are ignored (see notify method).
|
|
798
|
+
* - DIRTY and PENDING flags are still set when dependencies change.
|
|
799
|
+
* - The effect remains active and maintains its dependency links.
|
|
781
800
|
*
|
|
782
801
|
* Use cases:
|
|
783
|
-
* - Temporarily disable effects during bulk updates
|
|
784
|
-
* - Prevent effects from running during initialization
|
|
785
|
-
* - Control when side effects should execute
|
|
786
|
-
*
|
|
787
|
-
* @example
|
|
788
|
-
* ```typescript
|
|
789
|
-
* const count = signal(0);
|
|
790
|
-
* const runner = effect(() => console.log(count.value));
|
|
802
|
+
* - Temporarily disable effects during bulk updates.
|
|
803
|
+
* - Prevent effects from running during initialization.
|
|
804
|
+
* - Control when side effects should execute.
|
|
791
805
|
*
|
|
792
|
-
*
|
|
793
|
-
* count.value = 1; // Effect won't run
|
|
794
|
-
* count.value = 2; // Effect won't run
|
|
795
|
-
* runner.effect.resume(); // Effect runs once with latest value
|
|
796
|
-
* ```
|
|
806
|
+
* @returns {void}
|
|
797
807
|
*/
|
|
798
808
|
pause(): void;
|
|
799
809
|
/**
|
|
800
|
-
* Resume Effect execution
|
|
810
|
+
* Resume Effect execution.
|
|
801
811
|
*
|
|
802
812
|
* When an effect is resumed:
|
|
803
|
-
* - The PAUSED flag is cleared
|
|
813
|
+
* - The PAUSED flag is cleared.
|
|
804
814
|
* - If dependencies changed during pause (DIRTY or PENDING flags set),
|
|
805
|
-
* the effect executes immediately via notify()
|
|
806
|
-
* - If no changes occurred, the effect simply becomes active again
|
|
815
|
+
* the effect executes immediately via notify().
|
|
816
|
+
* - If no changes occurred, the effect simply becomes active again.
|
|
807
817
|
*
|
|
808
818
|
* State management:
|
|
809
|
-
* - Clears PAUSED flag atomically
|
|
810
|
-
* - Checks for accumulated DIRTY/PENDING flags
|
|
811
|
-
* - Triggers execution if needed
|
|
812
|
-
*
|
|
813
|
-
* @example
|
|
814
|
-
* ```typescript
|
|
815
|
-
* const count = signal(0);
|
|
816
|
-
* const runner = effect(() => console.log(count.value));
|
|
819
|
+
* - Clears PAUSED flag atomically.
|
|
820
|
+
* - Checks for accumulated DIRTY/PENDING flags.
|
|
821
|
+
* - Triggers execution if needed.
|
|
817
822
|
*
|
|
818
|
-
*
|
|
819
|
-
* count.value = 1; // Queued
|
|
820
|
-
* count.value = 2; // Queued
|
|
821
|
-
* runner.effect.resume(); // Executes once with count.value = 2
|
|
822
|
-
* ```
|
|
823
|
+
* @returns {void}
|
|
823
824
|
*/
|
|
824
825
|
resume(): void;
|
|
825
826
|
/**
|
|
826
|
-
* Execute the Effect function
|
|
827
|
+
* Execute the Effect function.
|
|
827
828
|
*
|
|
828
829
|
* Core execution flow:
|
|
829
830
|
* 1. Check if active
|
|
@@ -831,40 +832,46 @@ declare class EffectImpl<T = any> implements ReactiveNode {
|
|
|
831
832
|
* 3. Start tracking dependencies
|
|
832
833
|
* 4. Execute user function
|
|
833
834
|
* 5. End tracking, clean up stale dependencies
|
|
834
|
-
|
|
835
|
-
* @returns The return value of the effect function
|
|
835
|
+
*
|
|
836
|
+
* @returns {T} The return value of the effect function.
|
|
836
837
|
*/
|
|
837
838
|
run(): T;
|
|
838
839
|
private _job?;
|
|
839
840
|
/**
|
|
840
|
-
* Get or create the job function for this effect
|
|
841
|
+
* Get or create the job function for this effect.
|
|
842
|
+
*
|
|
843
|
+
* @returns {() => void} The job function.
|
|
841
844
|
*/
|
|
842
845
|
private getJob;
|
|
843
846
|
/**
|
|
844
|
-
* Notify that the Effect needs to execute
|
|
847
|
+
* Notify that the Effect needs to execute.
|
|
845
848
|
*
|
|
846
849
|
* Called by dependent reactive values.
|
|
847
850
|
* Decides whether to execute immediately or defer based on scheduling strategy.
|
|
851
|
+
*
|
|
852
|
+
* @returns {void}
|
|
848
853
|
*/
|
|
849
854
|
notify(): void;
|
|
850
855
|
/**
|
|
851
|
-
* Stop the Effect
|
|
856
|
+
* Stop the Effect.
|
|
852
857
|
*
|
|
853
858
|
* After stopping:
|
|
854
|
-
* - No longer responds to dependency changes
|
|
855
|
-
* - Disconnects all dependency links
|
|
856
|
-
* - Clears cached job function
|
|
857
|
-
* - Calls onStop callback
|
|
858
|
-
* - Verifies complete cleanup in development mode
|
|
859
|
+
* - No longer responds to dependency changes.
|
|
860
|
+
* - Disconnects all dependency links.
|
|
861
|
+
* - Clears cached job function.
|
|
862
|
+
* - Calls onStop callback.
|
|
863
|
+
* - Verifies complete cleanup in development mode.
|
|
864
|
+
*
|
|
865
|
+
* @returns {void}
|
|
859
866
|
*/
|
|
860
867
|
stop(): void;
|
|
861
868
|
}
|
|
862
869
|
/**
|
|
863
|
-
* Create and immediately execute an Effect
|
|
870
|
+
* Create and immediately execute an Effect.
|
|
864
871
|
*
|
|
865
|
-
* @param fn - The effect function
|
|
866
|
-
* @param options - Configuration options
|
|
867
|
-
* @returns Effect runner
|
|
872
|
+
* @param fn - The effect function.
|
|
873
|
+
* @param options - Configuration options.
|
|
874
|
+
* @returns {EffectRunner<T>} Effect runner.
|
|
868
875
|
*
|
|
869
876
|
* @example
|
|
870
877
|
* ```typescript
|
|
@@ -895,16 +902,17 @@ declare class EffectImpl<T = any> implements ReactiveNode {
|
|
|
895
902
|
*/
|
|
896
903
|
declare function effect<T = any>(fn: EffectFunction<T>, options?: EffectOptions): EffectRunner<T>;
|
|
897
904
|
/**
|
|
898
|
-
* Stop Effect execution
|
|
905
|
+
* Stop Effect execution.
|
|
899
906
|
*
|
|
900
|
-
* @param runner - The effect runner
|
|
907
|
+
* @param runner - The effect runner to stop.
|
|
908
|
+
* @returns {void}
|
|
901
909
|
*/
|
|
902
910
|
declare function stop(runner: EffectRunner): void;
|
|
903
911
|
/**
|
|
904
|
-
* Type guard - Check if value is an Effect
|
|
912
|
+
* Type guard - Check if value is an Effect instance.
|
|
905
913
|
*
|
|
906
|
-
* @param value - The value to check
|
|
907
|
-
* @returns
|
|
914
|
+
* @param value - The value to check.
|
|
915
|
+
* @returns {boolean} True if value is an Effect instance.
|
|
908
916
|
*/
|
|
909
917
|
declare function isEffect(value: any): value is EffectImpl;
|
|
910
918
|
/**
|
|
@@ -916,21 +924,15 @@ declare function isEffect(value: any): value is EffectImpl;
|
|
|
916
924
|
*/
|
|
917
925
|
type MemoEffectFn<T> = (prevState: T) => T;
|
|
918
926
|
/**
|
|
919
|
-
* Create a memoized Effect
|
|
927
|
+
* Create a memoized Effect.
|
|
920
928
|
*
|
|
921
929
|
* A memoized effect remembers the return value from the previous execution
|
|
922
930
|
* and passes it as a parameter on the next execution.
|
|
923
931
|
*
|
|
924
|
-
*
|
|
925
|
-
* -
|
|
926
|
-
* -
|
|
927
|
-
*
|
|
928
|
-
* - Difference detection
|
|
929
|
-
*
|
|
930
|
-
* @param fn - The memoized function
|
|
931
|
-
* @param initialState - Initial state
|
|
932
|
-
* @param options - Configuration options
|
|
933
|
-
* @returns Effect runner
|
|
932
|
+
* @param fn - The memoized function.
|
|
933
|
+
* @param initialState - Initial state.
|
|
934
|
+
* @param options - Configuration options.
|
|
935
|
+
* @returns {EffectRunner<void>} Effect runner.
|
|
934
936
|
*
|
|
935
937
|
* @example
|
|
936
938
|
* ```typescript
|
|
@@ -952,13 +954,10 @@ type MemoEffectFn<T> = (prevState: T) => T;
|
|
|
952
954
|
declare function memoEffect<T>(fn: MemoEffectFn<T>, initialState: T, options?: EffectOptions): EffectRunner<void>;
|
|
953
955
|
|
|
954
956
|
/**
|
|
955
|
-
* Execute a function in batch mode
|
|
956
|
-
*
|
|
957
|
-
* Executes the function in a batch context, where all Signal changes
|
|
958
|
-
* are deferred and processed together after the batch ends.
|
|
957
|
+
* Execute a function in batch mode.
|
|
959
958
|
*
|
|
960
|
-
* @param fn - The function to execute in batch mode
|
|
961
|
-
* @returns The return value of the function
|
|
959
|
+
* @param fn - The function to execute in batch mode.
|
|
960
|
+
* @returns The return value of the function.
|
|
962
961
|
*
|
|
963
962
|
* @example
|
|
964
963
|
* ```typescript
|
|
@@ -982,45 +981,27 @@ declare function memoEffect<T>(fn: MemoEffectFn<T>, initialState: T, options?: E
|
|
|
982
981
|
*/
|
|
983
982
|
declare function batch<T>(fn: () => T): T;
|
|
984
983
|
/**
|
|
985
|
-
* Start batch update
|
|
984
|
+
* Start batch update.
|
|
986
985
|
*
|
|
987
|
-
*
|
|
988
|
-
* During batch, Effects won't execute immediately.
|
|
986
|
+
* @returns {void}
|
|
989
987
|
*/
|
|
990
988
|
declare function startBatch(): void;
|
|
991
989
|
/**
|
|
992
|
-
* End batch update
|
|
993
|
-
*
|
|
994
|
-
* Decreases batch depth.
|
|
995
|
-
* When depth reaches zero, flush all queued Effects.
|
|
990
|
+
* End batch update.
|
|
996
991
|
*
|
|
997
|
-
*
|
|
998
|
-
*
|
|
999
|
-
* When the outermost batch ends:
|
|
1000
|
-
* 1. Flush all queued jobs (effects execute)
|
|
1001
|
-
* 2. Job queue is automatically cleared by flushJobs()
|
|
1002
|
-
* 3. Temporary flags (QUEUED, DIRTY) are cleared by effect execution
|
|
1003
|
-
*
|
|
1004
|
-
* ## Development Mode Checks
|
|
1005
|
-
*
|
|
1006
|
-
* In development mode, this function performs additional validation:
|
|
1007
|
-
* - Detects unbalanced batch calls (endBatch without startBatch)
|
|
1008
|
-
* - Prevents batchDepth from becoming negative
|
|
1009
|
-
* - Provides clear error messages to help debug batch management issues
|
|
992
|
+
* @returns {void}
|
|
1010
993
|
*/
|
|
1011
994
|
declare function endBatch(): void;
|
|
1012
995
|
/**
|
|
1013
|
-
* Check if currently in batch update mode
|
|
996
|
+
* Check if currently in batch update mode.
|
|
1014
997
|
*
|
|
1015
|
-
* @returns
|
|
998
|
+
* @returns True if currently in batch mode.
|
|
1016
999
|
*/
|
|
1017
1000
|
declare function isBatching(): boolean;
|
|
1018
1001
|
/**
|
|
1019
|
-
* Get current batch depth
|
|
1002
|
+
* Get current batch depth.
|
|
1020
1003
|
*
|
|
1021
|
-
*
|
|
1022
|
-
*
|
|
1023
|
-
* @returns Current batch nesting depth
|
|
1004
|
+
* @returns Current batch nesting depth.
|
|
1024
1005
|
*/
|
|
1025
1006
|
declare function getBatchDepth(): number;
|
|
1026
1007
|
|
|
@@ -1096,6 +1077,12 @@ interface StoreActions<S extends State> {
|
|
|
1096
1077
|
* @param callback - Function to call on action execution
|
|
1097
1078
|
*/
|
|
1098
1079
|
onAction$: (callback: StoreCallback<S>) => void;
|
|
1080
|
+
/**
|
|
1081
|
+
* Removes a previously registered action callback.
|
|
1082
|
+
*
|
|
1083
|
+
* @param callback - The callback to remove.
|
|
1084
|
+
*/
|
|
1085
|
+
offAction$: (callback: StoreCallback<S>) => void;
|
|
1099
1086
|
/**
|
|
1100
1087
|
* Resets the store state to its initial values.
|
|
1101
1088
|
*/
|
|
@@ -1121,11 +1108,11 @@ type StoreDefinition<S extends State, G extends Getters<S>, A extends Actions> =
|
|
|
1121
1108
|
* Creates a new store with the given definition.
|
|
1122
1109
|
* The store can be defined either as a class or as an options object.
|
|
1123
1110
|
*
|
|
1124
|
-
* @template S - The type of the store's state
|
|
1125
|
-
* @template G - The type of the store's getters
|
|
1126
|
-
* @template A - The type of the store's actions
|
|
1127
|
-
* @param storeDefinition - The store definition (class or options)
|
|
1128
|
-
* @returns A function that creates a new store instance
|
|
1111
|
+
* @template S - The type of the store's state.
|
|
1112
|
+
* @template G - The type of the store's getters.
|
|
1113
|
+
* @template A - The type of the store's actions.
|
|
1114
|
+
* @param storeDefinition - The store definition (class or options).
|
|
1115
|
+
* @returns A function that creates a new store instance.
|
|
1129
1116
|
*
|
|
1130
1117
|
* @example
|
|
1131
1118
|
* ```ts
|
|
@@ -1179,9 +1166,9 @@ interface Ref<T> extends Signal<T> {
|
|
|
1179
1166
|
* Creates a new ref with the given initial value.
|
|
1180
1167
|
* Unlike signals, refs don't create reactive proxies for object values.
|
|
1181
1168
|
*
|
|
1182
|
-
* @template T - The type of value to store in the ref
|
|
1183
|
-
* @param value - The initial value
|
|
1184
|
-
* @returns A new ref instance
|
|
1169
|
+
* @template T - The type of value to store in the ref.
|
|
1170
|
+
* @param value - The initial value.
|
|
1171
|
+
* @returns A new ref instance.
|
|
1185
1172
|
*
|
|
1186
1173
|
* @example
|
|
1187
1174
|
* ```ts
|
|
@@ -1193,9 +1180,9 @@ declare function ref<T>(value?: T): Ref<T>;
|
|
|
1193
1180
|
/**
|
|
1194
1181
|
* Type guard to check if a value is a Ref instance.
|
|
1195
1182
|
*
|
|
1196
|
-
* @template T - The type of value held by the ref
|
|
1197
|
-
* @param value - The value to check
|
|
1198
|
-
* @returns True if the value is a Ref instance
|
|
1183
|
+
* @template T - The type of value held by the ref.
|
|
1184
|
+
* @param value - The value to check.
|
|
1185
|
+
* @returns True if the value is a Ref instance.
|
|
1199
1186
|
*/
|
|
1200
1187
|
declare function isRef<T>(value: unknown): value is Ref<T>;
|
|
1201
1188
|
|
|
@@ -1209,10 +1196,11 @@ type WatchSource<T = any> = T | {
|
|
|
1209
1196
|
type WatchCallback<T = any> = (newValue: T, oldValue: T | undefined) => void;
|
|
1210
1197
|
/**
|
|
1211
1198
|
* Watch one or more reactive data sources and execute callback when sources change.
|
|
1199
|
+
*
|
|
1212
1200
|
* @param source - The source(s) to watch.
|
|
1213
1201
|
* @param callback - The callback function to execute when source changes.
|
|
1214
1202
|
* @param options - Configuration options like immediate and deep.
|
|
1215
|
-
* @returns A function to stop watching.
|
|
1203
|
+
* @returns {Function} A function to stop watching.
|
|
1216
1204
|
*/
|
|
1217
1205
|
declare function watch<T = any>(source: WatchSource<T>, callback: WatchCallback<T>, options?: WatchOptions): () => void;
|
|
1218
1206
|
|