{"_id":"@cather/kwc-signals","name":"@cather/kwc-signals","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"//":["THIS FILE IS AUTOGENERATED. If you modify it, it will be rewritten by check-and-rewrite-package-json.js","You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."],"name":"@cather/kwc-signals","version":"1.0.0","description":"Provides the interface to interact with reactivity from outside the framework","keywords":["kwc"],"homepage":"https://kwc.dev","repository":{"type":"git","url":"git+https://github.com/kingdee/kwc.git","directory":"packages/@kwc/signals"},"bugs":{"url":"https://github.com/kingdee/kwc/issues"},"license":"MIT","publishConfig":{"access":"public"},"volta":{"extends":"../../../package.json"},"main":"dist/index.cjs.js","module":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"rollup --config ../../../scripts/rollup/rollup.config.js","dev":"rollup  --config ../../../scripts/rollup/rollup.config.js --watch --no-watch.clearScreen"},"nx":{"targets":{"build":{"outputs":["{projectRoot}/dist"]}}},"devDependencies":{"@cather/kwc-shared":"1.0.0"},"_id":"@cather/kwc-signals@1.0.0","_nodeVersion":"20.19.4","_npmVersion":"10.8.2","dist":{"integrity":"sha512-tFAS0wsHqRZ/QJ6aF4Aw8CVtjHCY/tqUUP+2Xqe9xt4Rl3VhhEw8Ukc0WtvZXFjaJtEFm+KsYAZR/AXc9iRtLA==","shasum":"06a6e5ff8dd8e4a7807322a5eea1ab6dc6e34ff6","tarball":"https://registry.npmjs.org/@cather/kwc-signals/-/kwc-signals-1.0.0.tgz","fileCount":6,"unpackedSize":14392,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD47a5jOMM0bfCPSxvQFcV4RCUwe/8Mvp6eRtSedIvSMgIgfXg8dWVXY1G7067o8NLwUwr+cllQYzzB7tfVGquhgDE="}]},"_npmUser":{"name":"catherine2020","email":"303673522@qq.com"},"directories":{},"maintainers":[{"name":"catherine2020","email":"303673522@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/kwc-signals_1.0.0_1755877971186_0.476265581629274"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-22T15:52:51.080Z","1.0.0":"2025-08-22T15:52:51.368Z","modified":"2025-08-22T15:52:51.668Z"},"maintainers":[{"name":"catherine2020","email":"303673522@qq.com"}],"description":"Provides the interface to interact with reactivity from outside the framework","homepage":"https://kwc.dev","keywords":["kwc"],"repository":{"type":"git","url":"git+https://github.com/kingdee/kwc.git","directory":"packages/@kwc/signals"},"bugs":{"url":"https://github.com/kingdee/kwc/issues"},"license":"MIT","readme":"# @cather/kwc-signals\n\nThis is an experimental package containing the interface expected for signals.\n\nA key point to note is that when a signal is both bound to an KWC class member variable and used on a template,\nthe KWC engine will attempt to subscribe a callback to rerender the template.\n\n## Reactivity with Signals\n\nA Signal is an object that holds a value and allows components to react to changes to that value.\nIt exposes a `.value` property for accessing the current value, and `.subscribe` methods for responding to changes.\n\n```js\nimport { signal } from 'some/signals';\n\nexport default class ExampleComponent extends LightningElement {\n    count = signal(0);\n\n    increment() {\n        this.count.value++;\n    }\n}\n```\n\nIn the template, we can bind directly to the `.value` property:\n\n```html\n<template>\n    <button onclick=\"{increment}\">Increment</button>\n    <p>{count.value}</p>\n</template>\n```\n\n## Supported APIs\n\nThis package supports the following APIs.\n\n### Signal\n\nThis is the shape of the signal that the KWC engine expects.\n\n```js\nexport type OnUpdate = () => void;\nexport type Unsubscribe = () => void;\n\nexport interface Signal<T> {\n    get value(): T;\n    subscribe(onUpdate: OnUpdate): Unsubscribe;\n}\n```\n\n### SignalBaseClass\n\nA base class is provided as a starting point for implementation.\n\n```js\nexport abstract class SignalBaseClass<T> implements Signal<T> {\n    abstract get value(): T;\n\n    private subscribers: Set<OnUpdate> = new Set();\n\n    subscribe(onUpdate: OnUpdate) {\n        this.subscribers.add(onUpdate);\n        return () => {\n            this.subscribers.delete(onUpdate);\n        };\n    }\n\n    protected notify() {\n        for (const subscriber of this.subscribers) {\n            subscriber();\n        }\n    }\n}\n```\n","readmeFilename":"README.md","_rev":"1-9b723d6b76b1e9e727808b010074db68"}