{"id":16189294,"url":"https://github.com/caolan/signaller","last_synced_at":"2026-01-03T08:56:44.657Z","repository":{"id":247284311,"uuid":"825440072","full_name":"caolan/signaller","owner":"caolan","description":"State change notifications","archived":false,"fork":false,"pushed_at":"2024-07-10T07:59:08.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T13:46:26.181Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caolan.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":"2024-07-07T19:22:59.000Z","updated_at":"2024-12-31T08:33:24.000Z","dependencies_parsed_at":"2024-07-10T09:50:07.417Z","dependency_job_id":null,"html_url":"https://github.com/caolan/signaller","commit_stats":null,"previous_names":["caolan/signaller"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fsignaller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fsignaller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fsignaller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fsignaller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caolan","download_url":"https://codeload.github.com/caolan/signaller/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241444006,"owners_count":19963749,"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":[],"created_at":"2024-10-10T07:34:55.043Z","updated_at":"2026-01-03T08:56:44.623Z","avatar_url":"https://github.com/caolan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Signaller\n\nNotify subscribers after a value is updated.\n\nMultiple signals are handled efficiently, making this library useful to\npropagate new application state to components.\n\n~360 bytes (minified + gzipped).\n\n## Installation\n\nEither use `src/signaller.js` directly as a JavaScript module or install\nvia a package manager.\n\n```\nnpm install signaller\n```\n\n## Example\n\n```javascript\nimport {Signaller, watch} from \"signaller.js\";\n\n// Create some Signallers to hold state.\nconst name = new Signaller(\"Pickles\");\nconst count = new Signaller(10);\n\n// Watch state for changes.\nwatch([name, count], changed =\u003e {\n    console.log(`${name.value}: ${count.value}`);\n});\n\n// Multiple synchronous updates will not call the\n// watch handler multiple times.\nname.value = \"Bananas\";\nname.value = \"Cookies\";\ncount.value++;\n\n// Hmmm. More cookies, please.\nsetTimeout(() =\u003e count.value = 200, 1000);\n```\n\nOutput:\n\n```\nCookies: 11\nCookies: 200\n```\n\n## Tests\n\n```\ndeno test\n```\n\n## Signaller(initial)\n\nRepresents a value that may change multiple times.\n\n### Properties\n\n#### .value\n\nThe current value of the Signaller. Setting this property to a value that\nis not strictly equal to the old value will automatically call signal().\n\n### Methods\n\n#### .signal()\n\nTakes all callbacks from the waiting list (clearing it) and calls \neach callback synchronously in the order they were added.\n\nYou do not need to call this function directly unless you have\nmutated the underlying value and wish to signal the change to any\nwatchers manually.\n\n#### .addCallback(callback)\n\nAppends a callback to the waiting list that will be called on the next\nsignal. The callback function is called with this Signaller instance as\nits only argument. Its return value is ignored.\n\nNormally, you would use `watch()` instead of calling this method directly.\n\n#### .removeCallback(callback)\n\nRemoves the first matching callback from the waiting list (if \nany). Does nothing if callback has not been registered and will not\nthrow.\n\nNormally, you would use the stop function returned by `watch()` instead\nof calling this method directly.\n\n## watch(signallers, handler)\n\nWatches an Array of Signallers for changes.\n\nThe handler will always be called asynchronously following a\nsignal. Multiple signals before the next handler completes will not\nqueue multiple handler calls. This means not every intermediate value\nof a Signaller will necessarily be seen by the handler.\n\nThe handler receives an Array of Signaller instances that have signalled\nsince the last time the handler was called. If the handler returns a\nPromise, the handler will not be called again until the Promise completes.\n\n### Returns\n\nA function to stop watching for signals. After calling this function, the\nhandler is guaranteed to not be called by again even if a signal is queued.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaolan%2Fsignaller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaolan%2Fsignaller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaolan%2Fsignaller/lists"}