{"_id":"@dmytromykhailiuk/reactive","_rev":"1-e7f705cdbfc86e4e185510da75758124","name":"@dmytromykhailiuk/reactive","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@dmytromykhailiuk/reactive","version":"1.0.0","author":{"name":"Dmytro Mykhailiuk"},"license":"ISC","_id":"@dmytromykhailiuk/reactive@1.0.0","maintainers":[{"name":"dmytromykhailiuk","email":"dimamykhayluk@gmail.com"}],"homepage":"https://github.com/dmytromykhailiuk/signal#readme","bugs":{"url":"https://github.com/dmytromykhailiuk/signal/issues"},"dist":{"shasum":"9f1108ee49b9a0ea4d08e78411956bc1431937af","tarball":"https://registry.npmjs.org/@dmytromykhailiuk/reactive/-/reactive-1.0.0.tgz","fileCount":6,"integrity":"sha512-Y7Lok+1QMrVh8GWkOQ22mYO8B1yOtuB1cQsXbbkiK1tMXNlxSRvgC4PQQs397MmOHF27ngr5INsaPPYac3hKKA==","signatures":[{"sig":"MEYCIQDqBLfQ9Je0RHvDxOetAKVoQ7pH9PaZC0tHZTZpzNIDewIhAKflVmsdDQW1aEGUbYaIeE1ybtDWg+nIdapPNFYIIYL7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":39811},"main":"dist/src/index.js","types":"dist/src/index.d.ts","gitHead":"d2ba7e3adba4e4a0828b5b738178accefa59d4ce","scripts":{"compile":"npx tsc"},"_npmUser":{"name":"dmytromykhailiuk","email":"dimamykhayluk@gmail.com"},"repository":{"url":"git+https://github.com/dmytromykhailiuk/signal.git","type":"git"},"_npmVersion":"10.8.2","description":"Simple and Powerful Signal implementation","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.5","eslint":"^9.9.1","prettier":"^3.3.3","typescript":"^5.5.4","@types/node":"^22.5.4","eslint-plugin-node":"^11.1.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","@typescript-eslint/parser":"^8.4.0","eslint-config-airbnb-typescript":"^18.0.0","@typescript-eslint/eslint-plugin":"^8.4.0"},"_npmOperationalInternal":{"tmp":"tmp/reactive_1.0.0_1725627138763_0.4278846512873844","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@dmytromykhailiuk/reactive","version":"1.1.0","description":"Simple and Powerful Signal implementation","main":"dist/src/index.js","types":"dist/src/index.d.ts","scripts":{"compile":"npx tsc"},"repository":{"type":"git","url":"git+https://github.com/dmytromykhailiuk/signal.git"},"author":{"name":"Dmytro Mykhailiuk"},"license":"ISC","bugs":{"url":"https://github.com/dmytromykhailiuk/signal/issues"},"homepage":"https://github.com/dmytromykhailiuk/signal#readme","devDependencies":{"@types/node":"^22.5.4","@typescript-eslint/eslint-plugin":"^8.4.0","@typescript-eslint/parser":"^8.4.0","eslint":"^9.9.1","eslint-config-airbnb-typescript":"^18.0.0","eslint-config-prettier":"^9.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^5.2.1","husky":"^9.1.5","prettier":"^3.3.3","typescript":"^5.5.4"},"_id":"@dmytromykhailiuk/reactive@1.1.0","gitHead":"f8698b1e6f795da986e9d9e6e505c48e2be285d9","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-cXN0rD2Va5h0bp7grE/ea8CHTC4qo6km4ZWoPHo4JQFXxZt5wBEMKQoINcBndidlJa3NVuk1MKI547Ep7g2PSg==","shasum":"2f655d4103c67135ae86aef4df05ccc2df6d03b3","tarball":"https://registry.npmjs.org/@dmytromykhailiuk/reactive/-/reactive-1.1.0.tgz","fileCount":6,"unpackedSize":41651,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICR6ZeMmCBl31WWFPyq9Vc/n6MVYVgzhnzK1PM+dBEhuAiEArBijs14F+/mNIMsMOCHWTlhquWaOdk63+SCrn9z/LSQ="}]},"_npmUser":{"name":"dmytromykhailiuk","email":"dimamykhayluk@gmail.com"},"directories":{},"maintainers":[{"name":"dmytromykhailiuk","email":"dimamykhayluk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reactive_1.1.0_1727522017822_0.4107050772134764"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-06T12:52:18.614Z","modified":"2024-09-28T11:13:38.317Z","1.0.0":"2024-09-06T12:52:18.951Z","1.1.0":"2024-09-28T11:13:38.110Z"},"bugs":{"url":"https://github.com/dmytromykhailiuk/signal/issues"},"author":{"name":"Dmytro Mykhailiuk"},"license":"ISC","homepage":"https://github.com/dmytromykhailiuk/signal#readme","repository":{"type":"git","url":"git+https://github.com/dmytromykhailiuk/signal.git"},"description":"Simple and Powerful Signal implementation","maintainers":[{"name":"dmytromykhailiuk","email":"dimamykhayluk@gmail.com"}],"readme":"# Reactive\n\n**Simple and Powerful Signal implementation**\n\n## Installation\n\n```sh\nnpm i @dmytromykhailiuk/reactive\n```\n\n## Example of usage\n\n### Basic examples\n```typescript\nimport { Signal, ComputedSignal, SignalEffect, DebouncedSignalEffect } from '@dmytromykhailiuk/reactive';\n\nconst a = new Signal(1);\nconst b = new Signal(2);\nconst c = new ComputedSignal(() => a.value + b.value);\n\nconsole.log('ComputedSignal', c.value); \n// ComputedSignal 3\n\na.value = a.value + 1;\nb.value = b.value + 2;\nconsole.log('ComputedSignal', c.value); \n// ComputedSignal 6\n\nconst effect = new SignalEffect(() => console.log('SignalEffect', c.value));\n// SignalEffect 6\n\na.value = a.value + 1;\n// SignalEffect 7\na.value = a.value + 1;\n// SignalEffect 8\nb.value = b.value + 2;\n// SignalEffect 10\nb.value = b.value;\n\neffect.destroy();\n\nconst debouncedEffect = new DebouncedSignalEffect(() => console.log('DebouncedSignalEffect', c.value));\n// DebouncedSignalEffect 10\n\na.value = a.value + 1;\na.value = a.value + 1;\nb.value = b.value + 2;\n\n\n// DebouncedSignalEffect 14\n\n```\n\n### Ways to change the value of Signal\n```typescript\nconst example = new Signal(1);\n\n// Using setter of \"value\" field\nexample.value = 3; \nconsole.log(example.value); // 3\n\n\n// Using \"update\" method\nexample.update(5); \nconsole.log(example.value); // 5\n\n\n// Using \"update\" method with callback\nexample.update(prevValue => prevValue + 5);\nconsole.log(example.value); // 10\n\n```\n\n### Alternative way to watch for Signal or Computed using \"subscribe\"\n```typescript\nconst example = new Signal(0);\n\n// using \"subscribe\" method\nconst unsub = example.subscribe((value) => console.log('subscribe', value));\n\nexample.update(2);\n// subscribe 2\nexample.update(2);\nexample.update(4);\n// subscribe 4\nunsub();\n\n// \n\n```\n","readmeFilename":"README.md"}