@silvery/signals 0.5.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/package.json +30 -0
- package/src/index.ts +41 -0
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@silvery/signals",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Reactive signals for silvery — thin wrapper around alien-signals",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Bjørn Stabell <bjorn@stabell.org>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/beorn/silvery.git",
|
|
10
|
+
"directory": "packages/signals"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "src/index.ts",
|
|
17
|
+
"types": "src/index.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./src/index.ts",
|
|
21
|
+
"import": "./src/index.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"alien-signals": "^3.1.2"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
signal,
|
|
16
|
+
computed,
|
|
17
|
+
effect,
|
|
18
|
+
effectScope,
|
|
19
|
+
startBatch,
|
|
20
|
+
endBatch,
|
|
21
|
+
trigger,
|
|
22
|
+
isSignal,
|
|
23
|
+
isComputed,
|
|
24
|
+
isEffect,
|
|
25
|
+
isEffectScope,
|
|
26
|
+
getActiveSub,
|
|
27
|
+
setActiveSub,
|
|
28
|
+
getBatchDepth,
|
|
29
|
+
} from "alien-signals"
|
|
30
|
+
|
|
31
|
+
import { startBatch, endBatch } from "alien-signals"
|
|
32
|
+
|
|
33
|
+
/** Batch multiple signal updates, notifying subscribers once at the end. */
|
|
34
|
+
export function batch(fn: () => void): void {
|
|
35
|
+
startBatch()
|
|
36
|
+
try {
|
|
37
|
+
fn()
|
|
38
|
+
} finally {
|
|
39
|
+
endBatch()
|
|
40
|
+
}
|
|
41
|
+
}
|