{"id":13837629,"url":"https://github.com/WebReflection/signal","last_synced_at":"2025-07-10T18:34:03.139Z","repository":{"id":65430695,"uuid":"580688310","full_name":"WebReflection/signal","owner":"WebReflection","description":"An extremely basic signals implementation.","archived":false,"fork":false,"pushed_at":"2024-04-18T12:40:18.000Z","size":283,"stargazers_count":61,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-18T16:28:42.224Z","etag":null,"topics":["javascript","signals"],"latest_commit_sha":null,"homepage":"https://calendar.perfplanet.com/2022/signals-the-nitty-gritty/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebReflection.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-21T07:34:45.000Z","updated_at":"2024-11-04T00:04:47.000Z","dependencies_parsed_at":"2024-05-30T06:44:45.710Z","dependency_job_id":null,"html_url":"https://github.com/WebReflection/signal","commit_stats":{"total_commits":43,"total_committers":2,"mean_commits":21.5,"dds":"0.023255813953488413","last_synced_commit":"8bd91faae9724f3d902363b99e8a6866f82d904b"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fsignal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fsignal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fsignal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fsignal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebReflection","download_url":"https://codeload.github.com/WebReflection/signal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225653891,"owners_count":17502939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","signals"],"created_at":"2024-08-04T15:01:17.807Z","updated_at":"2024-11-21T00:30:52.800Z","avatar_url":"https://github.com/WebReflection.png","language":"JavaScript","readme":"# @webreflection/signal\n\n[![Coverage Status](https://coveralls.io/repos/github/WebReflection/signal/badge.svg?branch=main)](https://coveralls.io/github/WebReflection/signal?branch=main) [![build status](https://github.com/WebReflection/signal/actions/workflows/node.js.yml/badge.svg)](https://github.com/WebReflection/signal/actions)\n\n\u003csup\u003e**Social Media Photo by [Louis Reed](https://unsplash.com/@_louisreed) on [Unsplash](https://unsplash.com/)**\u003c/sup\u003e\n\nA minimalistic signals implementation, derived from the post [Signals: the nitty-gritty](https://calendar.perfplanet.com/2022/signals-the-nitty-gritty/), which size, once minified and brotlied, is 528 bytes.\n\n  * no automatic effect disposal except when an outer effect has inner effects and the outer effect `dispose()` is invoked\n  * computed are lazily initialied but updated per each signal change they depend on, unless a `batch` operation is updating all inner signals at once\n  * no fancy features from other libraries\n\nFor anything more complex please check [usignal](https://github.com/WebReflection/usignal#readme) out.\n\n### exports\n\n  * `signal(value)` to create a new signal with a reactive `.value`\n  * `computed(fn[, initialValue])` to create a computed signal with a read-only `.value`\n  * `effect(fn)` to create an effect and return a dispose function\n  * `batch(fn)` to update multiple signals at once and invoke related effects once\n  * `untracked(fn)` to make a callback that can read some signals without subscription to them\n  * `Signal` to compare via `instanceof Signal` instances\n  * `Computed` to compare via `instanceof Computed` instances\n\n*Computed* accepts an initial value to pass to the callback. The callback will keep receiving the previous value on each new invoke.\n\n\n### example\n\n```js\n// import {signal, effect} from 'https://unpkg.com/@webreflection/signal';\n// const {signal, effect} = require('@webreflection/signal');\nimport {signal, effect} from '@webreflection/signal';\n\nconst single = signal(1);\nconst double = signal(10);\nconst triple = signal(100);\n\nconst dispose1 = effect(() =\u003e {\n  console.log(`\n  #1 effect\n    single: ${single}\n    double: ${double}\n  `);\n});\n\nconst dispose2 = effect(() =\u003e {\n  console.log(`\n  #2 effect\n    double: ${double}\n    triple: ${triple}\n  `);\n});\n\n++double.value;\n// logs single 1, double 11\n// logs double 11, triple 100\n\ndispose2();\n\n++double.value;\n// logs single 1, double 11\n```\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebReflection%2Fsignal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWebReflection%2Fsignal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebReflection%2Fsignal/lists"}