{"id":13509645,"url":"https://github.com/mobxjs/mobx-vue","last_synced_at":"2025-04-12T20:44:08.255Z","repository":{"id":37686523,"uuid":"134814022","full_name":"mobxjs/mobx-vue","owner":"mobxjs","description":"🐉 Vue bindings for MobX","archived":false,"fork":false,"pushed_at":"2023-03-02T18:07:01.000Z","size":1611,"stargazers_count":478,"open_issues_count":22,"forks_count":20,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-10T10:26:00.406Z","etag":null,"topics":["javascript","mobx","mobx-vue","reactive-programming","vue"],"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/mobxjs.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}},"created_at":"2018-05-25T06:37:42.000Z","updated_at":"2025-04-01T02:40:06.000Z","dependencies_parsed_at":"2024-01-15T03:41:22.409Z","dependency_job_id":null,"html_url":"https://github.com/mobxjs/mobx-vue","commit_stats":{"total_commits":115,"total_committers":6,"mean_commits":"19.166666666666668","dds":0.4434782608695652,"last_synced_commit":"4c2825e0731f14a4fa8b81b13eac319514377344"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobxjs%2Fmobx-vue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobxjs%2Fmobx-vue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobxjs%2Fmobx-vue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobxjs%2Fmobx-vue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mobxjs","download_url":"https://codeload.github.com/mobxjs/mobx-vue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631687,"owners_count":21136556,"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","mobx-vue","reactive-programming","vue"],"created_at":"2024-08-01T02:01:10.914Z","updated_at":"2025-04-12T20:44:08.229Z","avatar_url":"https://github.com/mobxjs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","vue","Components \u0026 Libraries","Awesome MobX"],"sub_categories":["Utilities","Related projects and utilities"],"readme":"# mobx-vue\n\n[![Build Status](https://github.com/mobxjs/mobx-vue/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/stylus/stylus/actions?query=branch%3Amaster)\n[![npm version](https://img.shields.io/npm/v/mobx-vue.svg)](https://www.npmjs.com/package/mobx-vue)\n[![coverage](https://img.shields.io/codecov/c/github/mobxjs/mobx-vue.svg)](https://codecov.io/gh/mobxjs/mobx-vue)\n[![npm downloads](https://img.shields.io/npm/dt/mobx-vue.svg)](https://www.npmjs.com/package/mobx-vue)\n\nVue2 bindings for MobX, inspired by [mobx-react](https://github.com/mobxjs/mobx-react). Looking for Vue3 support? Please look here [mobx-vue-lite](https://github.com/mobxjs/mobx-vue-lite)\n\n![logo](https://github.com/mobxjs/mobx-vue/blob/master/logo.png?raw=true)\n\n## Support Table\n| package | mobx v6 | mobx v2/v3/v4/v5 | vue2 | vue3 | \n| ------  | ------- | ---------------- | ---- | ---- |\n| [mobx-vue](https://github.com/mobxjs/mobx-vue) | \u003e= v2.1.0 | * (exclude v2.1.0) | * | - |\n| [mobx-vue-lite](https://github.com/mobxjs/mobx-vue-lite) | * | - | - | * |\n\u003e `*` means `all` and `-` means `none`\n \n## Installation\n\n```bash\nnpm i mobx-vue -S\n```\n\nor\n\n```bash\nyarn add mobx-vue\n```\n\n## Why mobx-vue \n\nMobX is an unopinionated, scalable state management, which can make our programming more intuitive.\n\nUnlike the other vue-rx-inspired libraries which based on the plugin mechanism of vue, mobx-vue will be the simplest you ever meet. What you all need is to bind your state in component definition and observe it just like [mobx-react](https://github.com/mobxjs/mobx-react) does,  then your component will react to your state changes automatically which managed by mobx.\n\nAnd, the most important is that you can build a view-library-free application, if you wanna migrate to another view library(React/Angular) someday, rewrite the template and switch to the relevant mobx bindings([mobx-react](https://github.com/mobxjs/mobx-react),[mobx-angular](https://github.com/mobxjs/mobx-angular),[mobx-angularjs](https://github.com/mobxjs/mobx-angularjs)) is all you have to do.\n\n### Articles: \n\n* [Build A View-Framework-Free Data Layer Based on MobX — Integration With Vue](https://medium.com/@kuitos/build-a-view-framework-free-data-layer-based-on-mobx-integration-with-vue-1-8b524b86c7b8)\n\n* [Why MobX + movue, instead of Vuex?](https://github.com/nighca/movue/issues/8)\n* [基于 MobX 构建视图框架无关的数据层-与 Vue 的结合(1)](https://zhuanlan.zhihu.com/p/37736470)\n\n## Usage\n\nWe highly recommend using the bindings with [vue-class-component](https://github.com/vuejs/vue-class-component) decorator, and define the Store/ViewModel independently.\n\n```ts\nimport { action, computed, observable } from \"mobx\";\nexport default class ViewModel {\n    @observable age = 10;\n    @observable users = [];\n\n    @computed get computedAge() {\n        return this.age + 1;\n    }\n\n    @action.bound setAge() {\n        this.age++;\n    }\n    \n    @action.bound async fetchUsers() {\n    \tthis.users = await http.get('/users')\n    }\n}\n```\n\n```vue\n\u003ctemplate\u003e\n    \u003csection\u003e\n        \u003cp v-text=\"state.age\"\u003e\u003c/p\u003e\n        \u003cp v-text=\"state.computedAge\"\u003e\u003c/p\u003e\n        \u003cp v-for=\"user in state.users\" :key=\"user.name\"\u003e{{user.name}}\u003c/p\u003e\n        \u003cbutton @click=\"state.setAge\"\u003e\u003c/button\u003e\n    \u003c/section\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\n    import Vue from \"vue\";\n    import Component from \"vue-class-component\";\n    import { Observer } from \"mobx-vue\";\n    import ViewModel from \"./ViewModel\";\n\n    @Observer\n    @Component\n    export default class App extends Vue {\n        state = new ViewModel()\n        mounted() { \n            this.state.fetchUsers();\n        }\n    }\n\u003c/script\u003e\n```\n\nOr used with the traditional way:\n\n```vue\n\u003cscript lang=\"ts\"\u003e\n    import { observer } from \"mobx-vue\";\n    import ViewModel from \"./ViewModel\";\n\n    export default observer({\n        data() {\n            return { state: new ViewModel() }\n        },\n        mounted() {\n            this.state.fetchUsers() \n        }\n    })\n\u003c/script\u003e\n```\n\nAll you need is to bind your state to component and observe it. No more reactive data definitions in component.\n\n*Tips: If you're tired of instantiating instance manually every time, you might wanna try the [mmlpx](https://github.com/mmlpxjs/mmlpx) library which leveraged a dependency injection system.*\n\n## API\n\n* observer((VueComponent | options): ExtendedVueComponent\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobxjs%2Fmobx-vue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobxjs%2Fmobx-vue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobxjs%2Fmobx-vue/lists"}