{"id":39118986,"url":"https://github.com/dao42/wechat-weapp-mobx","last_synced_at":"2026-01-17T20:26:07.877Z","repository":{"id":54529735,"uuid":"86656610","full_name":"dao42/wechat-weapp-mobx","owner":"dao42","description":"微信小程序(wechat weapp) mobx 绑定, 跨页面通信的利器, 现已发布npm包","archived":false,"fork":false,"pushed_at":"2019-12-13T03:52:10.000Z","size":119,"stargazers_count":210,"open_issues_count":4,"forks_count":30,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-10-17T05:42:04.270Z","etag":null,"topics":["mobx","redux","weapp","wechat","wechat-framework","wechat-weapp"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dao42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-30T03:52:03.000Z","updated_at":"2024-04-11T14:42:46.000Z","dependencies_parsed_at":"2022-08-13T18:50:28.518Z","dependency_job_id":null,"html_url":"https://github.com/dao42/wechat-weapp-mobx","commit_stats":null,"previous_names":["80percent/wechat-weapp-mobx"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dao42/wechat-weapp-mobx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dao42%2Fwechat-weapp-mobx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dao42%2Fwechat-weapp-mobx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dao42%2Fwechat-weapp-mobx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dao42%2Fwechat-weapp-mobx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dao42","download_url":"https://codeload.github.com/dao42/wechat-weapp-mobx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dao42%2Fwechat-weapp-mobx/sbom","scorecard":{"id":112562,"data":{"date":"2025-08-11","repo":{"name":"github.com/dao42/wechat-weapp-mobx","commit":"cd9865641ee5be2f2ecb6142476679bc18d51c99"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 2/27 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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-15T13:11:21.207Z","repository_id":54529735,"created_at":"2025-08-15T13:11:21.207Z","updated_at":"2025-08-15T13:11:21.207Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28517573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T18:55:29.170Z","status":"ssl_error","status_checked_at":"2026-01-17T18:55:03.375Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["mobx","redux","weapp","wechat","wechat-framework","wechat-weapp"],"created_at":"2026-01-17T20:26:07.201Z","updated_at":"2026-01-17T20:26:07.872Z","avatar_url":"https://github.com/dao42.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\n微信小程序 mobx 绑定( wechat weapp mobx )\n==============\n\n页面间通信的利器\n\n为你的小程序添加mobx数据层驱动\n\n当前版本: 0.2.0\n\n依赖 mobx 版本: 4.9.2\n\n## 安装\n\n### 方式一: npm 包( 推荐 )\n\n小程序已经支持使用 npm 安装第三方包，详见 [npm 支持](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html?search-key=npm)\n\n```shell\nnpm install wechat-weapp-mobx -S --production\n```\n\n### 方式二: 手动安装\n\n1. clone或者下载代码库到本地:\n\n   ```shell\n    git clone https://github.com/dao42/wechat-weapp-mbox\n   ```\n2. 将 `dist/mobx.js`, `dist/diff.js` 和 `dist/observer.js` 文件直接拷贝到小程序的工程中,例如 (下面假设我们把第三方包都安装在libs目录下):\n\n   ```shell\n    cd wechat-weapp-mobx\n    cp mobx.js \u003c小程序根目录\u003e/libs\n    cp diff.js \u003c小程序根目录\u003e/libs\n    cp observer.js \u003c小程序根目录\u003e/libs\n   ```\n\n    上面的命令将包拷贝到小程序的`\u003c小程序根目录\u003e/libs`目录下\n\n3. 创建一个 `\u003c小程序根目录\u003e/stores` 目录, 存放数据层.\n\n## 使用( 使用 ES5 语法 )\n1. 创建 mobx 的 stores\n\n    ```js\n    // \u003c小程序根目录\u003e/stores/todoStore.js\n    // 手动安装时引入的路径\n    // var extendObservable = require('../../libs/mobx').extendObservable;\n    // npm 包安装引入的路径\n    var extendObservable = require('wechat-weapp-mobx/mobx').extendObservable;\n    var TodoStore = function() {\n      extendObservable(this, {\n        // observable data\n        todos: [],\n        todoText: 'aaa',\n        // computed data\n        get count() {\n          return this.todos.length;\n        }\n      });\n\n      // action\n      this.addTodo = function(title) {\n        this.todos.push( {title: title} );\n      }\n\n      this.removeTodo = function() {\n        this.todos.pop();\n      }\n    }\n\n    module.exports = {\n      default: new TodoStore,\n    }\n    ```\n\n2. 绑定页面联动事件\n\n    ```js\n    // \u003c小程序根目录\u003e/pages/index/index.js\n    // 手动安装时引入的路径\n    // var observer = require('../libs/observer').observer;\n    // npm 包安装引入的路径\n    var observer = require('wechat-weapp-mobx/observer').observer;\n    // 关键, 监控页面事件, 让 mobx 有机会更新页面数据\n    Page(observer({\n      props: {\n        todoStore: require('../stores/todoStore').default,\n      },\n      // your other code below\n      onLoad: function(){\n      }\n    }))\n    ```\n\n3. 说明\n\n    完成上述两步之后,你就可以在 wxml 中用 `props.todoStore` 这种方式来访问了, 并且数据联动已经自动工作.\n\n    ```js\n    // \u003c小程序根目录\u003e/pages/index/index.wxml\n    \u003cview\u003e{{props.todoStore.todoText}}\u003c/view\u003e\n    ```\n\n4. 数据自动联动\n\nstores 中的数据可以跨页面同时访问，并且数据更新后，页面也会自动更新。从而节省大量逻辑代码。\n\n## 组件中使用\n\n* 绑定组件联动事件\n\n```js\nComponent(observerComponment({\n  props: {\n    todoStore: require('../stores/todoStore').default\n  }\n}))\n```\n\n## ES6 语法示例\n\n请直接查看示例: [wechat-weapp-mobx-todos-npm](https://github.com/dao42/wechat-weapp-mobx-todos-npm)\n\n## 版本更新记录\n\n### 0.2.1\n\n* 支持组件中使用 `observerComponment` 语法\n\n### 0.2.0\n\n* 优化：提前将 props 注入 `page.data`，避免页面渲染过慢。\n\n### 0.1.9\n\n* （稳定性）经一段时间验证，项目稳定支持 mobx 4.9.2 版本。\n* 优化：修复一个可能引发联动问题的 observer 问题。\n* 优化：调整 Unload callback 执行顺序。\n* 推荐 0.1.8 的用户升级至 0.1.9。\n\n### 0.1.8\n\n* （重大）正式升级 mobx 至 4.9.2 版本，支持最新的 mobx 装饰器语法。\n* 尝试性支持 ES6 语法，如有bug，请及时反馈。\n\n感谢 [Danney](https://github.com/dannnney) 的贡献。\n\n### 0.1.7 (勿用)\n\n* 尝试性升级 mobx 至 4.9.2 版本，增加新的装饰器语法。\n* 但发现 mobx 4.9.2 版本下，props 数据对象会被小程序框架错误清空。\n\n### 0.1.6\n\n* 同步更新 npm 包至 0.1.6\n\n### 0.1.5\n\n* 优化 toJSWithGetter 接口, 性能再次提升2倍.\n* 调整目录, 发布 npm 包.\n\n### 0.1.4\n\n* 增加 diff 流程, 大幅提高触发性能\n\n### 0.1.3\n\n* 重构 autorun 机制, 提高触发性能.\n\n### 0.1.2\n\n* 重构 toJS 逻辑, 支持嵌套的 computed value 显示.\n* 支持 props 已有的属性值观测, 修改可以触发更新视图.\n\n### 0.1.1\n\n* 优化性能, 避免重复的 mobx toJS 对象.\n* 添加版本号支持.\n\n### 0.1.0\n\n* 实现 mobx 核心支持.\n\n## 示例( npm 整合，ES6 语法演示 )\n\n详细的使用例子可以参照: [wechat-weapp-mobx-todos-npm](https://github.com/dao42/wechat-weapp-mobx-todos-npm)\n\n真机实测版请clone下面这个repo，用小程序开发工具开启预览:\n\n```\ngit clone https://github.com/dao42/wechat-weapp-mobx-todos-npm.git\n```\n\n## 示例( 手动安装 )\n\n详细的使用例子可以参照: [wechat-weapp-mobx-todos](https://github.com/dao42/wechat-weapp-mobx-todos)\n\n真机实测版请clone下面这个repo，用小程序开发工具开启预览:\n\n```\ngit clone https://github.com/dao42/wechat-weapp-mobx-todos.git\n```\n\n## 实际案例\n\n**Ballu -- 一个实时的篮球计分工具**\n\n\u003e 点评: 此项目是一个非常 \"复杂\" 的小程序, 项目多处页面需要使用 websocket 与服务端进行同步的数据更新, 深度使用 `wechat-weapp-mobx` 作为数据驱动层后, 数据状态同步的问题轻松化解. 最终项目成功上线.\n\n![ballu](img/ballu.png)\n\n## 开发( 发布 npm 版本 )\n\n```bash\n$ npm login --registry https://registry.npmjs.org/\n$ npm publish\n```\n\n## 协议( LICENSE )\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdao42%2Fwechat-weapp-mobx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdao42%2Fwechat-weapp-mobx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdao42%2Fwechat-weapp-mobx/lists"}