{"id":28921822,"url":"https://github.com/playcanvas/observer","last_synced_at":"2026-01-06T17:20:04.897Z","repository":{"id":39996271,"uuid":"397897952","full_name":"playcanvas/observer","owner":"playcanvas","description":"TypeScript implementation of the Observer pattern","archived":false,"fork":false,"pushed_at":"2025-05-27T14:57:30.000Z","size":573,"stargazers_count":18,"open_issues_count":1,"forks_count":6,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-06-19T03:18:15.771Z","etag":null,"topics":["observer","observer-pattern","playcanvas","typescript"],"latest_commit_sha":null,"homepage":"https://api.playcanvas.com/observer/","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/playcanvas.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":"2021-08-19T10:05:42.000Z","updated_at":"2025-05-27T14:57:34.000Z","dependencies_parsed_at":"2024-03-14T15:02:00.877Z","dependency_job_id":"f2651fe3-bef1-4a8b-926b-57a712908e4b","html_url":"https://github.com/playcanvas/observer","commit_stats":{"total_commits":28,"total_committers":4,"mean_commits":7.0,"dds":0.6428571428571428,"last_synced_commit":"31334e96ef1f42bccbb22078d453adbd897d6ccd"},"previous_names":["playcanvas/observer","playcanvas/playcanvas-observer"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/playcanvas/observer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fobserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fobserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fobserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fobserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playcanvas","download_url":"https://codeload.github.com/playcanvas/observer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fobserver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261250335,"owners_count":23130544,"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":["observer","observer-pattern","playcanvas","typescript"],"created_at":"2025-06-22T07:08:22.362Z","updated_at":"2026-01-06T17:20:04.881Z","avatar_url":"https://github.com/playcanvas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Observer - Observer Pattern for JS/TS\n\n[![NPM Version](https://img.shields.io/npm/v/@playcanvas/observer)](https://www.npmjs.com/package/@playcanvas/observer)\n[![NPM Downloads](https://img.shields.io/npm/dw/@playcanvas/observer)](https://npmtrends.com/@playcanvas/observer)\n[![License](https://img.shields.io/npm/l/@playcanvas/observer)](https://github.com/playcanvas/observer/blob/main/LICENSE)\n[![Discord](https://img.shields.io/badge/Discord-5865F2?style=flat\u0026logo=discord\u0026logoColor=white\u0026color=black)](https://discord.gg/RSaMRzg)\n[![Reddit](https://img.shields.io/badge/Reddit-FF4500?style=flat\u0026logo=reddit\u0026logoColor=white\u0026color=black)](https://www.reddit.com/r/PlayCanvas)\n[![X](https://img.shields.io/badge/X-000000?style=flat\u0026logo=x\u0026logoColor=white\u0026color=black)](https://x.com/intent/follow?screen_name=playcanvas)\n\n| [User Manual](https://developer.playcanvas.com) | [API Reference](https://api.playcanvas.com/observer) | [Blog](https://blog.playcanvas.com) | [Forum](https://forum.playcanvas.com) |\n\nThe PlayCanvas Observer is a powerful TypeScript library for managing and observing changes to objects. It allows tracking modifications to nested properties, emitting events on changes, and maintaining state consistency. This is particularly useful in applications where state management and change tracking are critical, such as in data-driven interfaces or collaborative applications.\n\n## Installing\n\nTo install the NPM package, do:\n\n```\nnpm install @playcanvas/observer --save-dev\n```\n\n## Usage\n\n### Creating an Observer\n\n```javascript\nimport Observer from '@playcanvas/observer';\n\nconst data = {\n    name: 'John',\n    age: 30,\n    address: {\n        city: 'New York',\n        zip: '10001'\n    }\n};\n\nconst observer = new Observer(data);\n```\n\n### Listening for Changes\n\nYou can listen for changes to specific properties using the `on` method:\n\n```javascript\nobserver.on('address.city:set', (newValue, oldValue) =\u003e {\n    console.log(`City changed from ${oldValue} to ${newValue}`);\n});\n\nobserver.set('address.city', 'San Francisco'); // Logs: City changed from New York to San Francisco\n```\n\n## Building\n\nTo generate a UMD and ESM build of the Observer library, run:\n\n```\nnpm install\nnpm run build\n```\n\nThe UMD build is `dist/index.js`. The ESM build is `dist/index.mjs`.\n\n## API Docs\n\nTo build the API reference manual, run:\n\n```\nnpm run docs\n```\n\nA pre-built API reference manual is hosted [here](https://api.playcanvas.com/observer/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaycanvas%2Fobserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplaycanvas%2Fobserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaycanvas%2Fobserver/lists"}