{"id":15979218,"url":"https://github.com/perry-mitchell/obstate","last_synced_at":"2026-06-14T01:31:53.274Z","repository":{"id":58087456,"uuid":"529905232","full_name":"perry-mitchell/obstate","owner":"perry-mitchell","description":"Generic object state management with events","archived":false,"fork":false,"pushed_at":"2023-07-16T06:33:35.000Z","size":289,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T09:27:22.163Z","etag":null,"topics":[],"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/perry-mitchell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-08-28T15:42:22.000Z","updated_at":"2022-08-29T17:44:51.000Z","dependencies_parsed_at":"2023-01-19T19:30:54.104Z","dependency_job_id":null,"html_url":"https://github.com/perry-mitchell/obstate","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/perry-mitchell/obstate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fobstate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fobstate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fobstate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fobstate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perry-mitchell","download_url":"https://codeload.github.com/perry-mitchell/obstate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fobstate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34306772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-07T23:41:38.003Z","updated_at":"2026-06-14T01:31:53.246Z","avatar_url":"https://github.com/perry-mitchell.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ObState\n\u003e Generic object state management with events\n\n[![obstate](https://img.shields.io/npm/v/obstate?color=blue\u0026label=obstate\u0026logo=npm\u0026style=flat-square)](https://www.npmjs.com/package/obstate) ![Tests](https://github.com/perry-mitchell/obstate/actions/workflows/test.yml/badge.svg)\n\nSimple state manager that uses objects to store and track state. Manage the object normally as it additionally provides events to listen to state changes.\n\nObState uses `Proxy`s to handle state changes, and then emits events using a standard `EventEmitter` interface.\n\n## Usage\n\nImport the `createStateObject` method and use it to wrap an object (a new object is returned, the old is not mutated):\n\n```typescript\nimport { createStateObject } from \"obstate\";\n\nconst state = createStateObject({\n    name: \"Jane Doe\",\n    age: 24\n});\n\nstate.on(\n    \"before\",\n    ({ property, newValue, currentValue }) =\u003e\n        console.log(`Will update '${property}': ${currentValue} =\u003e ${newValue}`)\n);\nstate.on(\n    \"update\",\n    ({ property, newValue, oldValue }) =\u003e\n        console.log(`Did update '${property}':  ${oldValue} =\u003e ${newValue}`)\n);\n\nObject.assign(state, {\n    name: \"John Doe\",\n    age: 22\n});\n```\n\nThe example above would output:\n\n```\nWill update 'name': Jane Doe =\u003e John Doe\nDid update 'name':  Jane Doe =\u003e John Doe\nWill update 'age': 24 =\u003e 22\nDid update 'age':  24 =\u003e 22\n```\n\n### React\n\n[`react-obstate`](https://github.com/perry-mitchell/react-obstate) is a react toolkit that provides hooks for using state instances in React components.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperry-mitchell%2Fobstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperry-mitchell%2Fobstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperry-mitchell%2Fobstate/lists"}