@silvery/signals 0.29.0 → 0.29.3
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/index.d.mts +19 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @silvery/signals — Reactive signals for silvery.
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper around alien-signals providing:
|
|
5
|
+
* - signal(value) — create a reactive value (call to read, call with arg to write)
|
|
6
|
+
* - computed(fn) — derived reactive value that recomputes on dependency changes
|
|
7
|
+
* - effect(fn) — side effect that re-runs when dependencies change
|
|
8
|
+
* - effectScope(fn) — group effects for collective disposal
|
|
9
|
+
* - batch(fn) — batch multiple signal updates into one notification
|
|
10
|
+
* - watch(read, onChange) — change-only subscription (skips the seed fire)
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
1
14
|
import { computed, effect, effectScope, endBatch, getActiveSub, getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, setActiveSub, signal, startBatch, trigger } from "alien-signals";
|
|
2
|
-
//#region src/index.d.ts
|
|
3
15
|
/**
|
|
4
16
|
* A reactive value — callable getter/setter.
|
|
5
17
|
*
|
|
@@ -9,7 +21,7 @@ import { computed, effect, effectScope, endBatch, getActiveSub, getBatchDepth, i
|
|
|
9
21
|
* Matches the return shape of `signal<T>(initial)` from alien-signals, so any
|
|
10
22
|
* `signal()` result is assignable to `Signal<T>`.
|
|
11
23
|
*/
|
|
12
|
-
type Signal<T> = {
|
|
24
|
+
export type Signal<T> = {
|
|
13
25
|
(): T;
|
|
14
26
|
(value: T): void;
|
|
15
27
|
};
|
|
@@ -18,13 +30,13 @@ type Signal<T> = {
|
|
|
18
30
|
* effect/computed but cannot be written to. Matches the return shape of
|
|
19
31
|
* `computed<T>(fn)` from alien-signals.
|
|
20
32
|
*/
|
|
21
|
-
type ReadSignal<T> = () => T;
|
|
33
|
+
export type ReadSignal<T> = () => T;
|
|
22
34
|
/** Batch multiple signal updates, notifying subscribers once at the end. */
|
|
23
|
-
declare function batch(fn: () => void): void;
|
|
35
|
+
export declare function batch(fn: () => void): void;
|
|
24
36
|
/**
|
|
25
37
|
* Options for {@link watch}.
|
|
26
38
|
*/
|
|
27
|
-
interface WatchOptions<T> {
|
|
39
|
+
export interface WatchOptions<T> {
|
|
28
40
|
/** If true, fire `onChange` on the seed read with `(next, next)`. Default false (change-only). */
|
|
29
41
|
immediate?: boolean;
|
|
30
42
|
/** Equality predicate — handler fires only when `equals(next, prev)` is false. Default `Object.is`. */
|
|
@@ -49,7 +61,6 @@ interface WatchOptions<T> {
|
|
|
49
61
|
*
|
|
50
62
|
* Returns the effect's stop function.
|
|
51
63
|
*/
|
|
52
|
-
declare function watch<T>(read: () => T, onChange: (next: T, prev: T) => void, opts?: WatchOptions<T>): () => void;
|
|
53
|
-
|
|
54
|
-
export { ReadSignal, Signal, WatchOptions, batch, computed, effect, effectScope, endBatch, getActiveSub, getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, setActiveSub, signal, startBatch, trigger, watch };
|
|
64
|
+
export declare function watch<T>(read: () => T, onChange: (next: T, prev: T) => void, opts?: WatchOptions<T>): () => void;
|
|
65
|
+
export { computed, effect, effectScope, endBatch, getActiveSub, getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, setActiveSub, signal, startBatch, trigger };
|
|
55
66
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YA0CY,OAAO;MACb;GACH,OAAO;;;;;;;YAQE,WAAW,WAAW;;wBAGlB,MAAM;;;;iBAYL,aAAa;;EAE5B;;EAEA,UAAU,GAAG,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;wBAsBL,MAAM,GACpB,YAAY,GACZ,WAAW,MAAM,GAAG,MAAM,YAC1B,OAAM,aAAa"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, effect, effect as effect$1, effectScope, endBatch, endBatch as endBatch$1, getActiveSub, getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, setActiveSub, signal, startBatch, startBatch as startBatch$1, trigger } from "alien-signals";
|
|
2
|
-
|
|
2
|
+
// src/index.ts
|
|
3
3
|
/** Batch multiple signal updates, notifying subscribers once at the end. */
|
|
4
4
|
function batch(fn) {
|
|
5
5
|
startBatch$1();
|
|
@@ -46,7 +46,6 @@ function watch(read, onChange, opts = {}) {
|
|
|
46
46
|
onChange(next, old);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
//#endregion
|
|
50
49
|
export { batch, computed, effect, effectScope, endBatch, getActiveSub, getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, setActiveSub, signal, startBatch, trigger, watch };
|
|
51
50
|
|
|
52
51
|
//# sourceMappingURL=index.mjs.map
|