{"id":22972849,"url":"https://github.com/dobjs/dob-redux","last_synced_at":"2025-08-13T13:31:27.695Z","repository":{"id":57213778,"uuid":"109239222","full_name":"dobjs/dob-redux","owner":"dobjs","description":"bind dob to redux!","archived":false,"fork":false,"pushed_at":"2017-11-13T06:59:30.000Z","size":663,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-17T10:42:15.770Z","etag":null,"topics":["dob","dob-redux","redux"],"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/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-11-02T08:44:38.000Z","updated_at":"2019-06-20T08:15:53.000Z","dependencies_parsed_at":"2022-08-29T02:10:31.190Z","dependency_job_id":null,"html_url":"https://github.com/dobjs/dob-redux","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-redux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dobjs%2Fdob-redux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dobjs%2Fdob-redux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dobjs%2Fdob-redux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dobjs","download_url":"https://codeload.github.com/dobjs/dob-redux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228982259,"owners_count":18001488,"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","dob-redux","redux"],"created_at":"2024-12-14T23:19:57.678Z","updated_at":"2024-12-14T23:19:58.237Z","avatar_url":"https://github.com/dobjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dob-redux \u0026middot; [![CircleCI Status](https://img.shields.io/travis/dobjs/dob-redux/master.svg?style=flat)](https://travis-ci.org/dobjs/dob-redux) [![npm version](https://img.shields.io/npm/v/dob-redux.svg?style=flat)](https://www.npmjs.com/package/dob-redux) [![code coverage](https://img.shields.io/codecov/c/github/dobjs/dob-redux/master.svg)](https://codecov.io/github/dobjs/dob-redux)\n\n## Installation\n\n```bash\nnpm i dob-redux\n```\n\n## Usage\n\n```typescript\nimport { observable } from 'dob'\nimport { createReduxStore } from 'dob-redux'\nimport { Provider, connect } from \"react-redux\"\n\nclass User {\n  store = observable({\n    name: \"nick\",\n    age: 5,\n    articles: [{\n      title: \"book1\",\n      price: 59\n    }, {\n      title: \"book2\",\n      price: 63\n    }]\n  })\n\n  setName(name) {\n    this.store.name = name\n  }\n\n  addArticle(article) {\n    this.store.articles.push(article)\n  }\n}\n\nconst { store, actions } = createReduxStore({\n  user: User\n})\n\n@connect((state, ownProps) =\u003e {\n  return {\n    name: state.user.name,\n    articles: state.user.articles\n  }\n})\nclass App extends React.PureComponent {\n  componentWillMount() {\n    actions.user.addArticle({\n      \ttitle: \"book3\",\n        price: 66\n      })\n  }\n\n  render() {\n    const Articles = this.props.articles.map((article, index) =\u003e {\n      return (\n        \u003cdiv key={index}\u003e{article.title}, {article.price}\u003c/div\u003e\n      )\n    })\n\n    return (\n      \u003cdiv\u003e\n        {this.props.name}\n        {Articles}\n      \u003c/div\u003e\n    )\n  }\n}\n\nReactDOM.render(\n  \u003cProvider store={store}\u003e\n    \u003cApp /\u003e\n  \u003c/Provider\u003e,\n  document.getElementById(\"react-dom\")\n)\n```\n\n## Online Demo\n\nHere is a basic [demo](https://jsfiddle.net/56saqqvw/9/)\n\n## Apis\n\n### createReduxStore\n\nReturns a store that can be used by Redux.\n\n```typescript\nimport { createReduxStore } from 'dob-redux'\n\nclass Test {\n  store = observable({\n    age: 1\n  })\n\n  changeAge() {\n    this.store.age = 2\n  }\n}\n\ncreateReduxStore({\n  testStore: Test\n})\n```\n\n### onSnapshot\n\n```typescript\nimport { observable } from 'dob'\nimport { onSnapshot } from 'dob-redux'\n\nconst obj = observable({ a: 1 })\n\nonSnapshot(obj, snapshot =\u003e {\n  // each time obj's any property changed, an new snapshot will created here\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdobjs%2Fdob-redux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdobjs%2Fdob-redux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdobjs%2Fdob-redux/lists"}