{"id":19303369,"url":"https://github.com/jsheaven/reactive","last_synced_at":"2025-04-22T11:32:03.624Z","repository":{"id":65818172,"uuid":"600611763","full_name":"jsheaven/reactive","owner":"jsheaven","description":"Nano library for functional, opt-in reactive programming","archived":false,"fork":false,"pushed_at":"2023-02-12T03:19:24.000Z","size":42,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T22:40:39.049Z","etag":null,"topics":["functional-programming","javasript","opt-in","reactive-programming","typescript"],"latest_commit_sha":null,"homepage":"","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/jsheaven.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":"2023-02-12T02:40:51.000Z","updated_at":"2024-02-22T20:27:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae678550-f5fa-44ee-b274-8f47fa317443","html_url":"https://github.com/jsheaven/reactive","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"94dc2d9b29bbbd34631b0a95a443375462e49425"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Freactive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Freactive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Freactive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Freactive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsheaven","download_url":"https://codeload.github.com/jsheaven/reactive/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250232193,"owners_count":21396588,"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":["functional-programming","javasript","opt-in","reactive-programming","typescript"],"created_at":"2024-11-09T23:26:10.540Z","updated_at":"2025-04-22T11:32:03.348Z","avatar_url":"https://github.com/jsheaven.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003e@jsheaven/reactive\u003c/h1\u003e\n\n\u003e Nano library for functional, opt-in reactive programming\n\n\u003ch2 align=\"center\"\u003eUser Stories\u003c/h2\u003e\n\n1. As a developer, I (sometimes) want a function to re-run when the data that it depends on, changes\n\n\u003ch2 align=\"center\"\u003eFeatures\u003c/h2\u003e\n\n- ✅ Makes `Function`s reactive so that they re-run when data in reactive objects they use, changes\n- ✅ Makes `Object`s reactive so that when values in them are changed, reactive `Functions` re-run\n- ✅ Available as a simple API\n- ✅ Just `397 byte` nano sized (ESM, gizpped)\n- ✅ Tree-shakable and side-effect free\n- ✅ One `@jsheaeven` dependency: `@jsheaven/observed`\n- ✅ First class TypeScript support\n- ✅ 100% Unit Test coverage\n\n\u003ch2 align=\"center\"\u003eExample usage\u003c/h2\u003e\n\n\u003ch3 align=\"center\"\u003eSetup\u003c/h3\u003e\n\n- yarn: `yarn add @jsheaven/reactive`\n- npm: `npm install @jsheaven/reactive`\n\n\u003ch3 align=\"center\"\u003eESM\u003c/h3\u003e\n\n```ts\nimport { reactive, on } from '@jsheaven/reactive'\n\nconst state = reactive({ rand: 0 })\nconst otherState = reactive({ rand: 0 })\n\nreactive(() =\u003e {\n  // using state.rand makes this function re-run when setInterval changes it\n  console.log('Next random value', on(state.rand))\n\n  // but using a state like otherState.rand, that isn't maked for reactivity, will never trigger\n  console.log('Prev random value (lags behind)', otherState.rand)\n})\n\nlet i = 0\nconst interval = setInterval(() =\u003e {\n  state.rand = otherState.rand // this mutation causes the reactive function to re-run\n  otherState.rand = Math.random() // this however, is numb\n\n  if (i === 9) {\n    clearInterval(interval) // stops re-running the reactive function\n  }\n}, 1000)\n```\n\n\u003ch3 align=\"center\"\u003eCommonJS\u003c/h3\u003e\n\n```ts\nconst { reactive, on } = require('@jsheaven/reactive')\n\n// same API like ESM variant\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsheaven%2Freactive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsheaven%2Freactive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsheaven%2Freactive/lists"}