{"id":13401030,"url":"https://github.com/mobxjs/mobx","last_synced_at":"2025-12-12T04:07:38.427Z","repository":{"id":28695728,"uuid":"32215970","full_name":"mobxjs/mobx","owner":"mobxjs","description":"Simple, scalable state management.","archived":false,"fork":false,"pushed_at":"2025-04-07T19:52:43.000Z","size":20077,"stargazers_count":27866,"open_issues_count":66,"forks_count":1782,"subscribers_count":331,"default_branch":"main","last_synced_at":"2025-05-05T13:57:54.338Z","etag":null,"topics":["javascript","mobx","react","reactive-programming","typescript"],"latest_commit_sha":null,"homepage":"http://mobx.js.org","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/mobxjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"mobx"}},"created_at":"2015-03-14T14:31:38.000Z","updated_at":"2025-05-05T13:32:55.000Z","dependencies_parsed_at":"2023-01-16T22:16:36.179Z","dependency_job_id":"239e485b-57d6-42dc-836b-bc44b6255bd4","html_url":"https://github.com/mobxjs/mobx","commit_stats":{"total_commits":2898,"total_committers":358,"mean_commits":8.094972067039107,"dds":"0.41062801932367154","last_synced_commit":"e3f26fcd401f7134438264d7e7606fb0664a6405"},"previous_names":["mweststrate/mobservable"],"tags_count":353,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobxjs%2Fmobx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobxjs%2Fmobx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobxjs%2Fmobx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobxjs%2Fmobx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mobxjs","download_url":"https://codeload.github.com/mobxjs/mobx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252614126,"owners_count":21776552,"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":["javascript","mobx","react","reactive-programming","typescript"],"created_at":"2024-07-30T19:00:58.023Z","updated_at":"2025-12-12T04:07:38.420Z","avatar_url":"https://github.com/mobxjs.png","language":"TypeScript","funding_links":["https://opencollective.com/mobx"],"categories":["Uncategorized","TypeScript","四、状态管理与数据获取","State Management","Utilities","JavaScript","cross framework","Marks","工具","Awesome MobX","前端开发框架及项目","Explanation of each State Management","Reactive Programming","数据流","目录","React","Reactive Programming [🔝](#readme)","📖 Categories","React [🔝](#readme)","响应式编程","Rax","List"],"sub_categories":["Uncategorized","1. 状态管理（同步状态）","State Management","Similar libraries","其他","Official Resources","其他_文本生成、文本对话","Mobx","Runner","macros","State management","运行器","运行器e2e测试","\u003ca id=\"state\"\u003e状态管理\u003c/a\u003e","MobX","Graphics \u0026 Drawing"],"readme":"\u003cimg src=\"https://mobx.js.org/assets/mobx.png\" alt=\"logo\" height=\"120\" align=\"right\" /\u003e\n\n# MobX\n\n_Simple, scalable state management._\n\n[![npm version](https://badge.fury.io/js/mobx.svg)](https://badge.fury.io/js/mobx)\n[![OpenCollective](https://opencollective.com/mobx/backers/badge.svg)](docs/backers-sponsors.md#backers)\n[![OpenCollective](https://opencollective.com/mobx/sponsors/badge.svg)](docs/backers-sponsors.md#sponsors)\n[![Discuss on Github](https://img.shields.io/badge/discuss%20on-GitHub-orange)](https://github.com/mobxjs/mobx/discussions)\n[![Coverage Status](https://coveralls.io/repos/github/mobxjs/mobx/badge.svg?branch=main)](https://coveralls.io/github/mobxjs/mobx?branch=main)\n[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/mobx)\n\n---\n\n## Documentation\n\nDocumentation can be found at **[mobx.js.org](https://mobx.js.org/)**.\n\n---\n\n## Sponsors\n\nMobX is made possible by the generosity of the sponsors below, and many other [individual backers](https://github.com/mobxjs/mobx/blob/main/docs/backers-sponsors.md#backers). Sponsoring directly impacts the longevity of this project.\n\n**🥇🥇 Platinum sponsors (\\$5000+ total contribution): 🥇🥇**\n\n\u003cbr/\u003e\n\u003ca href=\"https://www.guilded.gg/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/guilded.jpg\" align=\"center\" width=\"100\" title=\"Guilded\" alt=\"Guilded\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.canva.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/canva.svg\" align=\"center\" width=\"100\" title=\"Canva\" alt=\"Canva\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.getparallax.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/parallax.png\" align=\"center\" width=\"100\" title=\"Parallax\" alt=\"Parallax\" /\u003e\u003c/a\u003e\n\n**🥇 Gold sponsors (\\$2500+ total contribution):**\n\n\u003cbr/\u003e\n\u003ca href=\"https://www.one-beyond.com\"\u003e\u003cimg src=\"https://mobx.js.org/assets/dcsl.png\" align=\"center\" width=\"100\" title=\"One Beyond\" alt=\"One Beyond\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://frontendmasters.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/frontendmasters.jpg\" align=\"center\" width=\"100\" title=\"Frontend Masters\" alt=\"Frontend Masters\"\u003e\u003c/a\u003e\n\u003ca href=\"http://auctionfrontier.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/auctionfrontier.jpeg\" align=\"center\" width=\"100\" title=\"Auction Frontier\" alt=\"Auction Frontier\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.codefirst.co.uk/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/codefirst.png\" align=\"center\" width=\"100\" title=\"CodeFirst\" alt=\"CodeFirst\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://modulz.app/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/modulz.png\" align=\"center\" width=\"100\" title=\"Modulz\" alt=\"Modulz\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://coinbase.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/coinbase.jpeg\" align=\"center\" width=\"100\" title=\"Coinbase\" alt=\"Coinbase\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://curology.com/blog/tech\"\u003e\u003cimg src=\"https://mobx.js.org/assets/curology.png\" align=\"center\" width=\"100\" title=\"Curology\" alt=\"Curology\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://mendix.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/mendix-logo.png\" align=\"center\" width=\"100\" title=\"Mendix\" alt=\"Mendix\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://opensource.facebook.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/fbos.jpeg\" align=\"center\" width=\"100\" title=\"Facebook Open Source\" alt=\"Facebook Open Source\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://casinosites.ltd.uk/?utm_source=sponsorship\u0026utm_medium=mobx\u0026utm_campaign=readme\"\u003e\u003cimg src=\"https://mobx.js.org/assets/casino2.png\" align=\"center\" width=\"100\" title=\"Casino Sites\" alt=\"Casino Sites\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://www.bugsnag.com/platforms/react-error-reporting?utm_source=MobX\u0026utm_medium=Website\u0026utm_content=open-source\u0026utm_campaign=2019-community\u0026utm_term=20190913\"\u003e\u003cimg src=\"https://mobx.js.org/assets/bugsnag.jpg\" align=\"center\" width=\"100\" title=\"Bugsnag\" alt=\"Bugsnag\"/\u003e\u003c/a\u003e\n\n**🥈 Silver sponsors (\\$500+ total contributions):**\u003cbr/\u003e\n\n\u003ca href=\"https://mantro.net/jobs/warlock\"\u003e\u003cimg src=\"https://mobx.js.org/assets/mantro.png\" align=\"center\" width=\"100\" title=\"mantro GmbH\" alt=\"mantro GmbH\"\u003e\u003c/a\u003e\n\u003ca href=\"https://xh.io/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/xh.png\" align=\"center\" width=\"100\" title=\"Extremely Heavy Industries\" alt=\"Extremely Heavy Industries\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.algolia.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/algolia.jpg\" align=\"center\" width=\"100\" title=\"Algolia\" alt=\"Algolia\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://space307.com/?utm_source=sponsorship\u0026utm_medium=mobx\u0026utm_campaign=readme\"\u003e\u003cimg src=\"https://mobx.js.org/assets/space307.png\" align=\"center\" width=\"100\" title=\"Space307\" alt=\"Space307\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://blokt.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/blokt.jpg\" align=\"center\" width=\"100\" title=\"Blokt\" alt=\"Blokt\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://upper.co/?utm_source=github_mobxjs_sponsorship\u0026utm_medium=paid_acquisition\u0026utm_campaign=sponsorship\"\u003e\u003cimg src=\"https://mobx.js.org/assets/upper.png\" align=\"center\" width=\"100\" title=\"UPPER\" alt=\"UPPER\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://careers.dazn.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/dazn.png\" align=\"center\" width=\"100\" title=\"DAZN\" alt=\"DAZN\"\u003e\u003c/a\u003e\n\u003ca href=\"https://talentplot.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/talentplot.png\" align=\"center\" width=\"100\" title=\"talentplot\" alt=\"talentplot\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.easeus.com/?utm_source=github_mobxjs_sponsorship\u0026utm_medium=readme\u0026utm_campaign=sponsorship\"\u003e\u003cimg src=\"https://mobx.js.org/assets/easeus.png\" align=\"center\" width=\"100\" title=\"EaseUS\" alt=\"EaseUS\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://route4me.com/\"\u003e\u003cimg src=\"https://mobx.js.org/assets/route4me.png\" align=\"center\" width=\"100\" title=\"Route Planner and Route Optimizer\" alt=\"Route Planner and Route Optimizer\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://handsontable.com/docs/react-data-grid/?utm_source=Mobx_homepage\u0026utm_medium=sponsorship\u0026utm_campaign=library_sponsorship\"\u003e\u003cimg src=\"https://mobx.js.org/assets/handsontable.png\" align=\"center\" width=\"100\" title=\"Handsontable\" alt=\"Handsontable\"/\u003e\u003c/a\u003e\n\n## Introduction\n\n_Anything that can be derived from the application state, should be. Automatically._\n\nMobX is a signal based, battle-tested library that makes state management simple and scalable by transparently applying functional reactive programming.\nThe philosophy behind MobX is simple:\n\n\u003cdiv class=\"benefits\"\u003e\n    \u003cdiv\u003e\n        \u003cdiv class=\"pic\"\u003e😙\u003c/div\u003e\n        \u003cdiv\u003e\n            \u003ch4\u003eStraightforward\u003c/h4\u003e\n            \u003cp\u003eWrite minimalistic, boilerplate-free code that captures your intent.\n            Trying to update a record field? Simply use a normal JavaScript assignment —\n            the reactivity system will detect all your changes and propagate them out to where they are being used.\n            No special tools are required when updating data in an asynchronous process.\n            \u003c/p\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n        \u003cdiv class=\"pic\"\u003e🚅\u003c/div\u003e\n        \u003cdiv\u003e\n            \u003ch4\u003eEffortless optimal rendering\u003c/h4\u003e\n            \u003cp\u003e\n                All changes to and uses of your data are tracked at runtime, building a dependency tree that captures all relations between state and output.\n                This guarantees that computations that depend on your state, like React components, run only when strictly needed.\n                There is no need to manually optimize components with error-prone and sub-optimal techniques like memoization and selectors.\n            \u003c/p\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n        \u003cdiv class=\"pic\"\u003e🤹🏻‍♂️\u003c/div\u003e\n        \u003cdiv\u003e\n            \u003ch4\u003eArchitectural freedom\u003c/h4\u003e\n            \u003cp\u003e\n                MobX is unopinionated and allows you to manage your application state outside of any UI framework.\n                This makes your code decoupled, portable, and above all, easily testable.\n            \u003c/p\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n\n---\n\n## A quick example\n\nSo what does code that uses MobX look like?\n\n```javascript\nimport React from \"react\"\nimport ReactDOM from \"react-dom\"\nimport { makeAutoObservable } from \"mobx\"\nimport { observer } from \"mobx-react-lite\"\n\n// Model the application state.\nfunction createTimer() {\n    return makeAutoObservable({\n        secondsPassed: 0,\n        increase() {\n            this.secondsPassed += 1\n        },\n        reset() {\n            this.secondsPassed = 0\n        }\n    })\n}\n\nconst myTimer = createTimer()\n\n// Build a \"user interface\" that uses the observable state.\nconst TimerView = observer(({ timer }) =\u003e (\n    \u003cbutton onClick={() =\u003e timer.reset()}\u003eSeconds passed: {timer.secondsPassed}\u003c/button\u003e\n))\n\nReactDOM.render(\u003cTimerView timer={myTimer} /\u003e, document.body)\n\n// Update the 'Seconds passed: X' text every second.\nsetInterval(() =\u003e {\n    myTimer.increase()\n}, 1000)\n```\n\nThe `observer` wrapper around the `TimerView` React component will automatically detect that rendering\ndepends on the `timer.secondsPassed` observable, even though this relationship is not explicitly defined. The reactivity system will take care of re-rendering the component when _precisely that_ field is updated in the future.\n\nEvery event (`onClick` / `setInterval`) invokes an _action_ (`myTimer.increase` / `myTimer.reset`) that updates _observable state_ (`myTimer.secondsPassed`).\nChanges in the observable state are propagated precisely to all _computations_ and _side effects_ (`TimerView`) that depend on the changes being made.\n\n\u003cimg alt=\"MobX unidirectional flow\" src=\"https://mobx.js.org/assets/flow2.png\" align=\"center\" /\u003e\n\nThis conceptual picture can be applied to the above example, or any other application using MobX.\n\n## Getting started\n\nTo learn about the core concepts of MobX using a larger example, check out **[The gist of MobX](https://mobx.js.org/the-gist-of-mobx.html)** page, or take the **[10 minute interactive introduction to MobX and React](https://mobx.js.org/getting-started)**.\nThe philosophy and benefits of the mental model provided by MobX are also described in great detail in the blog posts [UI as an afterthought](https://michel.codes/blogs/ui-as-an-afterthought) and [How to decouple state and UI (a.k.a. you don’t need componentWillMount)](https://hackernoon.com/how-to-decouple-state-and-ui-a-k-a-you-dont-need-componentwillmount-cc90b787aa37).\n\n## Further resources\n\n-   The [MobX cheat sheet](https://gum.co/fSocU) (£5) is both useful and sponsors the project\n-   [10 minute interactive introduction to MobX and React](https://mobx.js.org/getting-started)\n-   [Egghead.io course, based on MobX 3](https://egghead.io/courses/manage-complex-state-in-react-apps-with-mobx)\n-   The [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx) – a long list of MobX resources and example projects\n\n### The MobX book\n\n\u003ca href=\"https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837\"\u003e\u003cimg src=\"https://mobx.js.org/assets/book.jpg\" height=\"120px\" /\u003e\u003c/a\u003e\n\nThe **[MobX Quick Start Guide](https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837)** ($24.99) by [Pavan Podila](https://twitter.com/pavanpodila) and [Michel Weststrate](https://twitter.com/mweststrate) is available as an [ebook](https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837), [paperback](https://www.amazon.com/MobX-Quick-Start-Guide-Supercharge/dp/1789344832), and on the [O'Reilly platform](https://www.oreilly.com/library/view/mobx-quick-start/9781789344837/) (see [preview](https://books.google.com/books?id=ALFmDwAAQBAJ\u0026printsec=frontcover#v=onepage\u0026q\u0026f=false)).\n\n### Videos\n\n-   [Introduction to MobX \u0026 React in 2020](https://www.youtube.com/watch?v=pnhIJA64ByY) by Leigh Halliday, _17 min_.\n-   [ReactNext 2016: Real World MobX](https://www.youtube.com/watch?v=Aws40KOx90U) by Michel Weststrate, _40 min_, [slides](https://docs.google.com/presentation/d/1DrI6Hc2xIPTLBkfNH8YczOcPXQTOaCIcDESdyVfG_bE/edit?usp=sharing).\n-   [CityJS 2020: MobX, from mutable to immutable, to observable data](https://youtu.be/sP7dtZm_Wx0?t=27050) by Michel Weststrate, _30 min_.\n-   [OpenSourceNorth: Practical React with MobX (ES5)](https://www.youtube.com/watch?v=XGwuM_u7UeQ) by Matt Ruby, _42 min_.\n-   [HolyJS 2019: MobX and the unique symbiosis of predictability and speed](https://www.youtube.com/watch?v=NBYbBbjZeX4\u0026list=PL8sJahqnzh8JJD7xahG5zXkjfM5GOgcPA\u0026index=21\u0026t=0s) by Michel Weststrate, _59 min_.\n-   [React Amsterdam 2016: State Management Is Easy](https://www.youtube.com/watch?v=ApmSsu3qnf0\u0026feature=youtu.be) by Michel Weststrate, _20 min_, [slides](https://speakerdeck.com/mweststrate/state-management-is-easy-introduction-to-mobx).\n-   {🚀} [React Live 2019: Reinventing MobX](https://www.youtube.com/watch?v=P_WqKZxpX8g) by Max Gallo, _27 min_.\n\n## Credits\n\nMobX is inspired by reactive programming principles, which are for example used in spreadsheets. It is inspired by model–view–viewmodel frameworks like [MeteorJS's Tracker](https://docs.meteor.com/api/tracker.html), [Knockout](https://knockoutjs.com/) and [Vue.js](https://vuejs.org/), but MobX brings _transparent functional reactive programming_ (TFRP, a concept which is further explained in the [MobX book](https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837)) to the next level and provides a standalone implementation. It implements TFRP in a glitch-free, synchronous, predictable and efficient manner.\n\nA ton of credit goes to [Mendix](https://github.com/mendix), for providing the flexibility and support to maintain MobX and the chance to prove the philosophy of MobX in a real, complex, performance critical applications.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobxjs%2Fmobx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobxjs%2Fmobx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobxjs%2Fmobx/lists"}