{"id":23881308,"url":"https://github.com/brundonsmith/model","last_synced_at":"2026-04-20T04:02:31.140Z","repository":{"id":57305679,"uuid":"92567684","full_name":"brundonsmith/model","owner":"brundonsmith","description":"Mutable, observable state for use with frameworks like React","archived":false,"fork":false,"pushed_at":"2017-10-12T03:28:25.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-11T21:19:16.656Z","etag":null,"topics":["mutable","observable","react","state"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mutable-model","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brundonsmith.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-05-27T03:26:45.000Z","updated_at":"2021-04-19T01:18:09.000Z","dependencies_parsed_at":"2022-08-28T21:02:20.531Z","dependency_job_id":null,"html_url":"https://github.com/brundonsmith/model","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/brundonsmith/model","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brundonsmith%2Fmodel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brundonsmith%2Fmodel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brundonsmith%2Fmodel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brundonsmith%2Fmodel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brundonsmith","download_url":"https://codeload.github.com/brundonsmith/model/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brundonsmith%2Fmodel/sbom","scorecard":{"id":255147,"data":{"date":"2025-08-11","repo":{"name":"github.com/brundonsmith/model","commit":"4613ae0c7916825b305e843de38e0e1cc1a29271"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/9 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T09:30:28.349Z","repository_id":57305679,"created_at":"2025-08-17T09:30:28.349Z","updated_at":"2025-08-17T09:30:28.349Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32032302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"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":["mutable","observable","react","state"],"created_at":"2025-01-04T01:00:00.038Z","updated_at":"2026-04-20T04:02:31.124Z","avatar_url":"https://github.com/brundonsmith.png","language":"JavaScript","readme":"# Model\n\nThis is a JavaScript class intended to serve as an alternative to React's normal `state` system. It utilizes ES6 Proxy to recursively intercept all assignment and deletion operations on all nested objects, and trigger a \"publication\" to registered subscribers with the new value.\n\nIn practical terms, this gives the developer a completely mutable, arbitrarily complex state object that will re-render a React component when any part of it is modified. This even applies to array mutation methods.\n\n# Usage\n\n```jsx\nvar Model = require('mutable-model');\n\nclass ShoppingCart extends React.Component {\n\n  componentWillMount() {\n    this.model = new Model(this, {\n      user: {\n        firstName: 'Bob',\n        lastName: 'Belcher'\n      },\n      items: [ ]\n    });\n  }\n\n  render() {\n    ...\n  }\n\n  handleUserFirstNameChange(newVal) {\n    /**\n     * Normal React method:\n     *\n     * var newUser = this.state.user;\n     * newUser.firstName = newVal;\n     * this.setState({\n     *   user: newUser\n     * });\n     *\n     */\n\n    this.model.user.firstName = newVal;\n  }\n\n  handleAddItemClick(item) {\n    /**\n     * Normal React method:\n     *\n     * this.setState({\n     *   items: this.state.items.concat([ item ]);\n     * });\n     *\n     */\n\n    this.model.items.push(item);\n  }\n\n}\n```\n\n# About Performance\nIt should be noted that unless extra measures are taken, Model tends to sacrifice a little bit of performance in exchange for better syntax. By that I mean, it can trigger a few extra renders. Consider the following:\n```jsx\nthis.setState({\n  varOne: 12,\n  varTwo: 'foo'\n});\n```\nIn the normal React style, this would only trigger one render. Whereas:\n```jsx\nthis.model.varOne = 12;\nthis.model.varTwo = 'foo';\n```\nThis would trigger two renders, because there are two separate assignment operations. Also, in cases like array mutation, there will often be two renders triggered; one for the addition (or removal) of the item, and one for the modification of `.length` (a separate, internal property assignment).\n\nThat said, this can be avoided on a case-by-case basis by mimicking the React style. This:\n```jsx\nthis.model.myArr = this.model.myArr.concat([ 'foo' ]);\n```\nwill only trigger one render, because there is only one assignment being performed. This also works for objects, in addition to arrays.\n\nIn summary, take advantage of the mutation syntax when it will simplify your code, and feel free to use the single-assignment style if you need to optimize. Model gives you the flexibility to do both.\n\n# Flexibility\nModel was designed and intended for managing complex React component state, but a subscriber to a Model doesn't have to be a React component, it can be any function. You could, for example, say:\n```jsx\nvar myModel = new Model(\n  function(model) {\n    console.log(JSON.stringify(model));\n  },\n  {\n    someNumber: 12\n  }\n);\n\nmyModel.someNumber = 100; // would print \"{someNumber:100}\" to the console\n```\nPassing a component as a subscriber directly is just for convenience; under the hood, all it does is call the component's `setState({})` method with an empty object; this doesn't change the React state but still triggers an update.\n\n# Misc Notes\n- It turns out, proxies don't transparently forward operations related to so-called \"exotic object\"; ones that have hidden properties, like Dates and, well, Proxies. I ran into a case where having a Date object in the model (wrapped in a proxy) was breaking all of its methods, so I made a change to exclude Date objects from being proxied. The model will still publish if a Date is assigned into something else, but not if it's mutated.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrundonsmith%2Fmodel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrundonsmith%2Fmodel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrundonsmith%2Fmodel/lists"}