{"id":13780609,"url":"https://github.com/dobjs/dob","last_synced_at":"2025-04-12T23:38:11.171Z","repository":{"id":57213822,"uuid":"83315560","full_name":"dobjs/dob","owner":"dobjs","description":" Light and fast 🚀 state management tool using proxy.","archived":false,"fork":false,"pushed_at":"2018-12-17T15:26:29.000Z","size":595,"stargazers_count":731,"open_issues_count":2,"forks_count":35,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-12T23:38:07.207Z","etag":null,"topics":["dob","dynamic","dynamic-object","observable","observe","observer","proxy","react"],"latest_commit_sha":null,"homepage":"https://dobjs.github.io/dob-docs/","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/dobjs.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":"2017-02-27T13:52:31.000Z","updated_at":"2025-04-08T10:24:15.000Z","dependencies_parsed_at":"2022-08-29T07:00:29.557Z","dependency_job_id":null,"html_url":"https://github.com/dobjs/dob","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dobjs%2Fdob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dobjs%2Fdob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dobjs%2Fdob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dobjs%2Fdob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dobjs","download_url":"https://codeload.github.com/dobjs/dob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647255,"owners_count":21139081,"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":["dob","dynamic","dynamic-object","observable","observe","observer","proxy","react"],"created_at":"2024-08-03T18:01:17.799Z","updated_at":"2025-04-12T23:38:11.143Z","avatar_url":"https://github.com/dobjs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","List"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://avatars1.githubusercontent.com/u/32093464?s=400\u0026u=d360e449a9d59cf7422100349711ab0e0389d06a\u0026v=4\" height=100/\u003e\n    \u003ch2 align=\"center\"\u003eDob\u003c/h2\u003e\n    \u003cp align=\"center\"\u003e\n        \u003ci\u003e\n            Dob is a tool for monitoring object changes. Using \u003ca target=\"_blank\" href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy\"\u003eProxy\u003c/a\u003e. \u003ca target=\"_blank\" href=\"https://dobjs.github.io/dob-docs/\"\u003eOnline Docs\u003c/a\u003e.\n        \u003c/i\u003e\n    \u003cp\u003e\n    \u003cp align=\"center\"\u003e\n        \u003ci\u003e\n            \u003ca href=\"https://travis-ci.org/dobjs/dob\"\u003e\n              \u003cimg src=\"https://img.shields.io/travis/dobjs/dob/master.svg?style=flat\" alt=\"CircleCI Status\"\u003e\n            \u003c/a\u003e\n            \u003ca href=\"https://www.npmjs.com/package/dob\"\u003e\n              \u003cimg src=\"https://img.shields.io/npm/v/dob.svg?style=flat\" alt=\"NPM Version\"\u003e\n            \u003c/a\u003e\n            \u003ca href=\"https://codecov.io/github/dobjs/dob\"\u003e\n              \u003cimg src=\"https://img.shields.io/codecov/c/github/dobjs/dob/master.svg\" alt=\"Code Coverage\"\u003e\n            \u003c/a\u003e\n        \u003c/i\u003e\n    \u003c/p\u003e\n\u003c/p\u003e\n\n## Examples\n\nThere are some [demo](https://jsfiddle.net/1q772uL0/20/) on fiddle. Here's the simplest:\n\n```typescript\nimport { observable, observe } from \"dob\";\n\nconst obj = observable({ a: 1 });\n\nobserve(() =\u003e {\n  console.log(\"obj.a has changed to\", obj.a);\n}); // \u003c· obj.a has changed to 1\n\nobj.a = 2; // \u003c· obj.a has changed to 2\n```\n\nYou can enjoy the benefits of proxy, for example `obj.a = { b: 5 }` is effective.\n\n## Use in react component\n\n```typescript\nimport { Action, observable, combineStores, inject } from \"dob\";\nimport { Connect } from \"dob-react\";\n\n@observable\nexport class UserStore {\n  name = \"bob\";\n}\n\nexport class UserAction {\n  @inject(UserStore) userStore: UserStore;\n\n  @Action\n  setName() {\n    this.userStore.name = \"lucy\";\n  }\n}\n\n@Connect(\n  combineStores({\n    UserStore,\n    UserAction\n  })\n)\nclass App extends React.Component {\n  render() {\n    return (\n      \u003cspan onClick={this.props.UserAction.setName}\u003e\n        {this.props.UserStore.name}\n      \u003c/span\u003e\n    );\n  }\n}\n```\n\n\u003e Use `inject` to pick stores in action, do not `new UserStore()`, it's terrible for later maintenance.\n\n## Use in react project\n\n```typescript\nimport { Action, observable, combineStores, inject } from \"dob\";\nimport { Provider, Connect } from \"dob-react\";\n\n@observable\nexport class UserStore {\n  name = \"bob\";\n}\n\nexport class UserAction {\n  @inject(UserStore) userStore: UserStore;\n\n  @Action\n  setName() {\n    this.userStore.name = \"lucy\";\n  }\n}\n\n@Connect\nclass App extends React.Component {\n  render() {\n    return (\n      \u003cspan onClick={this.props.UserAction.setName}\u003e\n        {this.props.UserStore.name}\n      \u003c/span\u003e\n    );\n  }\n}\n\nReactDOM.render(\n  \u003cProvider\n    {...combineStores({\n      UserStore,\n      UserAction\n    })}\n  \u003e\n    \u003cApp /\u003e\n  \u003c/Provider\u003e,\n  document.getElementById(\"react-dom\")\n);\n```\n\n## Project Examples\n\n* [dob-react simple example](https://github.com/ascoders/dob-example)\n* [dob-react hackernews](https://github.com/dobjs/dob-react-hackernews)\n* [dob-react todoMVC](https://github.com/dobjs/dob-react-todomvc)\n* [dob-react complex online web editor](https://github.com/ascoders/gaea-editor)\n* [dob-redux todoMVC](https://github.com/dobjs/dob-redux-todomvc)\n\n## Ecosystem\n\n* [dob-react](https://github.com/dobjs/dob-react) - Connect dob to react! Here is a basic [demo](https://jsfiddle.net/yp90Lep9/21/), and here is a [demo](https://jsfiddle.net/g19ehhgu/11/) with fractal. [Quick start](./docs/dob-react.md).\n* [dob-react-devtools](https://github.com/dobjs/dob-react-devtools) - Devtools for dob-react, with action and ui two way binding.\n* [dob-redux](https://github.com/dobjs/dob-redux) - You can use both dob and Redux by using it! Enjoy the type and convenience of dob, and the ecology of Redux.\n\n## Communication\n\nTalk to us about dob using DingDing.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/7970947/40582019-39bdd16e-619b-11e8-8e82-43cf529a9fff.JPG\" width=500/\u003e\n\n## Note\n\n### Dependency injection does not support circular references\n\nDo not allow circular dependencies between store and action, It's impossible to do like this:\n\n```typescript\nclass A {\n  @inject(B) b;\n}\nclass B {\n  @inject(A) a;\n}\n```\n\n### Do not deconstruct to the last level on dynamic object\n\n```typescript\nconst obj = observable({ a: 1 });\n\n// good\nobj.a = 5;\n// bad\nlet { a } = obj;\na = 5;\n```\n\n## Inspired\n\n* [mobx](https://github.com/mobxjs/mobx)\n* [nx-js](https://github.com/nx-js/observer-util)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdobjs%2Fdob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdobjs%2Fdob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdobjs%2Fdob/lists"}