{"id":47606163,"url":"https://github.com/rliang/reaffect","last_synced_at":"2026-04-01T19:24:10.752Z","repository":{"id":57348803,"uuid":"170333806","full_name":"rliang/reaffect","owner":"rliang","description":"Reactive side-effect container for Javascript apps","archived":false,"fork":false,"pushed_at":"2019-03-11T19:10:50.000Z","size":91,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T21:27:43.597Z","etag":null,"topics":["functional","javascript","reactive","side-effects"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/rliang.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}},"created_at":"2019-02-12T14:39:39.000Z","updated_at":"2019-03-11T19:10:51.000Z","dependencies_parsed_at":"2022-09-18T10:53:04.181Z","dependency_job_id":null,"html_url":"https://github.com/rliang/reaffect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rliang/reaffect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rliang%2Freaffect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rliang%2Freaffect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rliang%2Freaffect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rliang%2Freaffect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rliang","download_url":"https://codeload.github.com/rliang/reaffect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rliang%2Freaffect/sbom","scorecard":{"id":778583,"data":{"date":"2025-08-11","repo":{"name":"github.com/rliang/reaffect","commit":"ff6439e498c79e338c411d4d63fbdcca56a8bb73"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/25 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"75 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-257v-vj4p-3w2h","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-7r28-3m3f-r2pr","Warn: Project is vulnerable to: GHSA-r8j5-h5cx-65gg","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-92xj-mqp7-vmcj","Warn: Project is vulnerable to: GHSA-wxgw-qj99-44c2","Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5","Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp","Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq","Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr","Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765","Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g","Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-566m-qj78-rww5","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3","Warn: Project is vulnerable to: GHSA-hgch-jjmr-gp7w","Warn: Project is vulnerable to: GHSA-r3x4-wr4h-pw33","Warn: Project is vulnerable to: GHSA-876r-hj45-fw7g","Warn: Project is vulnerable to: GHSA-v63x-xc9j-hhvq","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-w5q7-3pr9-x44w","Warn: Project is vulnerable to: GHSA-3fjq-93xj-3f3f","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-x9hc-rw35-f44h","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T04:18:34.880Z","repository_id":57348803,"created_at":"2025-08-23T04:18:34.880Z","updated_at":"2025-08-23T04:18:34.880Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291132,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["functional","javascript","reactive","side-effects"],"created_at":"2026-04-01T19:24:09.603Z","updated_at":"2026-04-01T19:24:10.748Z","avatar_url":"https://github.com/rliang.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reaffect\n[![npm](https://img.shields.io/npm/v/reaffect.svg)](https://www.npmjs.org/package/reaffect)\n[![size](https://img.shields.io/bundlephobia/minzip/reaffect.svg)](https://bundlephobia.com)\n[![deps](https://david-dm.org/rliang/reaffect/status.svg)](https://david-dm.org/rliang/reaffect)\n\nReaffect is a reactive effect container for Javascript apps.\n\nIt allows writing business logic as generator functions\nwhere each yield point specifies a set of active effects,\nwhich are then automatically started, cancelled or kept active.\n\nThis means effects are reactive.\nThat is, they reflect the current state of the application.\n\n- 📚 [API](index.d.ts)\n- ⚡ [Examples](example)\n\n## Getting started\n\n### Installation\n\n```sh\nnpm i reaffect\n```\n\n### Defining effects\n\nAn effect is just a function\nwhich takes a *dispatcher* function as the first argument,\nand returns a *canceller* function.\n\nThe dispatcher function\ntakes a value as the first argument,\nand whether the effect is finished as the second argument.\n\n```js\nfunction SendEachSecond(dispatch, valueToSend) {\n  const id = setInterval(() =\u003e dispatch(valueToSend, false), 1000)\n  return () =\u003e clearInterval(id)\n}\n```\n\nIn the following examples,\nwe can see that effects can be wrapped\ninto higher-order effects that process the events\nthey receive in some way.\n\n```js\nconst WithLog = (dispatch, f, ...args) =\u003e {\n  const str = JSON.stringify([f.name, ...args])\n  console.log(`${str} started`)\n  const cancel = f((value, done) =\u003e {\n    if (!done)\n      console.log(`${str} sent \"${value}\"`)\n    dispatch(value, done)\n  }, ...args)\n  return () =\u003e { cancel(); console.log(`${str} cancelled`) }\n}\n```\n\n```js\nconst WithTakeN = (dispatch, n, f, ...args) =\u003e {\n  let k = 0\n  return f((value, done) =\u003e dispatch(value, done || k++ \u003c n), ...args)\n}\n```\n\n```js\nconst WithDiscard = (dispatch, f, ...args) =\u003e\n  f((value, done) =\u003e done \u0026\u0026 dispatch(null, done), ...args)\n```\n\n### Activating effects\n\nActivating effects and retrieving their sent values\ncan be done inside a generator function\nor any object with a `next` method.\n\n```js\nimport { reaffect } from 'reaffect'\n\nfunction* app() { \n  while (true) {\n    const msg = yield [\n      [SendEachSecond, 'hello'],\n      [WithLog, SendEachSecond, 'world'],\n    ]\n    console.log(msg)\n  }\n}\n\nreaffect(app())\n```\n\nIn the following example,\nwe can see that generators are composable through `yield*`.\n\n```js\nfunction* screen1() { \n  while (true) {\n    const msg = yield [/* ... */]\n    if (msg === 'screen2')\n      yield* screen2()\n  }\n}\n```\n\nThe following example wraps a generator\ninto a higher-order generator\nthat logs all events it receives.\n\n```js\nconst withLogAll = gen =\u003e ({\n  next(v) {\n    let { done, value } = gen.next(v)\n    return { done, value: done ? undefined : value.map(e =\u003e e \u0026\u0026 [WithLog, ...e]) }\n  }\n})\n```\n\n## [Examples](#examples)\n\n### React counter\n\n```js\nimport React from 'react'\nimport { render } from 'react-dom'\nimport { reaffect } from 'reaffect'\n\nconst SendEachSecond = (dispatch, value) =\u003e\n  clearInterval.bind(this, setInterval(dispatch, 1000, value))\n\nconst Render = (dispatch, count) =\u003e {\n  render(\n    \u003cdiv\u003e\n      \u003cdiv\u003e{count}\u003c/div\u003e\n      \u003cbutton onClick={() =\u003e dispatch('increase')}\u003e+1\u003c/button\u003e\n      \u003cbutton onClick={() =\u003e dispatch('decrease')}\u003e-1\u003c/button\u003e\n    \u003c/div\u003e\n  , document.getElementById('root')))\n  return () =\u003e dispatch = () =\u003e {}\n}\n\nfunction* app() { \n  let count = 0\n  while (true) {\n    const msg = yield [\n      [Render, count], \n      count \u003e 0 \u0026\u0026 [SendEachSecond, 'decrease'],\n      count \u003c 0 \u0026\u0026 [SendEachSecond, 'increase'],\n    ]\n    switch (msg) {\n      case 'increase':\n        count++\n        break\n      case 'decrease':\n        count--\n        break\n    }\n  }\n}\n\nreaffect(app())\n```\n\n## Compatibility with Async Iterators\n\nAlthough async iterators are not really immediately cancellable,\n`.return()` will do it after the next promise resolves.\n\n```js\nconst WrapAsyncIterator = (dispatch, f, ...args) =\u003e {\n  const it = (async () =\u003e {\n    for await (const v of f(...args))\n      dispatch(v)\n    dispatch(null, true)\n  })()\n  return () =\u003e it.return()\n}\n```\n\n## Acknowledgements\n\nThis library is inspired by\n[hyperapp](https://github.com/jorgebucaran/hyperapp/tree/V2)\nand [Elm](https://elm-lang.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frliang%2Freaffect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frliang%2Freaffect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frliang%2Freaffect/lists"}