{"id":13509653,"url":"https://github.com/mmlpxjs/mmlpx","last_synced_at":"2026-01-14T19:09:01.966Z","repository":{"id":23547601,"uuid":"99301797","full_name":"mmlpxjs/mmlpx","owner":"mmlpxjs","description":"🐘 mobx model layer paradigm","archived":false,"fork":false,"pushed_at":"2022-12-07T17:33:35.000Z","size":1163,"stargazers_count":180,"open_issues_count":20,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-19T11:39:57.437Z","etag":null,"topics":["architecture","layers","mobx","mvvm","paradigm","snapshot","time-travel"],"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/mmlpxjs.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-08-04T04:07:55.000Z","updated_at":"2025-07-25T06:59:41.000Z","dependencies_parsed_at":"2023-01-13T23:28:29.009Z","dependency_job_id":null,"html_url":"https://github.com/mmlpxjs/mmlpx","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/mmlpxjs/mmlpx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmlpxjs%2Fmmlpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmlpxjs%2Fmmlpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmlpxjs%2Fmmlpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmlpxjs%2Fmmlpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmlpxjs","download_url":"https://codeload.github.com/mmlpxjs/mmlpx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmlpxjs%2Fmmlpx/sbom","scorecard":{"id":654507,"data":{"date":"2025-08-11","repo":{"name":"github.com/mmlpxjs/mmlpx","commit":"103618b88a5f8c9a3a06207a4c23dafb59fb1da9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"Code-Review","score":0,"reason":"Found 1/26 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":"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":"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":"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":"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":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: 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":"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"}},{"name":"Vulnerabilities","score":0,"reason":"62 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-c6rq-rjc2-86v2","Warn: Project is vulnerable to: GHSA-mh2h-6j8q-x246","Warn: Project is vulnerable to: GHSA-5q88-cjfq-g2mh","Warn: Project is vulnerable to: GHSA-xp63-6vf5-xf3v","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-675m-85rw-j3w4","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T14:18:15.620Z","repository_id":23547601,"created_at":"2025-08-21T14:18:15.620Z","updated_at":"2025-08-21T14:18:15.620Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28431532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["architecture","layers","mobx","mvvm","paradigm","snapshot","time-travel"],"created_at":"2024-08-01T02:01:11.002Z","updated_at":"2026-01-14T19:09:01.949Z","avatar_url":"https://github.com/mmlpxjs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Awesome MobX"],"sub_categories":["Related projects and utilities"],"readme":"# mmlpx\n\n[![npm version](https://img.shields.io/npm/v/mmlpx.svg?style=flat-square)](https://www.npmjs.com/package/mmlpx)\n[![coverage](https://img.shields.io/codecov/c/github/mmlpxjs/mmlpx.svg?style=flat-square)](https://codecov.io/gh/mmlpxjs/mmlpx)\n[![npm downloads](https://img.shields.io/npm/dt/mmlpx.svg?style=flat-square)](https://www.npmjs.com/package/mmlpx)\n[![Build Status](https://img.shields.io/travis/mmlpxjs/mmlpx.svg?style=flat-square)](https://travis-ci.org/mmlpxjs/mmlpx)\n\nmmlpx is an abbreviation of **mobx model layer paradigm**, inspired by [CQRS](https://docs.microsoft.com/en-us/azure/architecture/patterns/cqrs) and [Android Architecture Components](https://developer.android.google.cn/topic/libraries/architecture/), aims to provide a mobx-based generic layered architecture for single page application.\n\n\u003e ![undefiend](https://cdn.nlark.com/yuque/0/2019/png/200577/1566621752079-3713029f-0357-4c4d-a3e2-4eea7080312e.png)\n## Installation\n\n```bash\nnpm i mmlpx -S\n```\n\nor\n\n```bash\nyarn add mmlpx\n```\n\n## Requirements\n\n* MobX: ^3.2.1 || ^4.0.0 || ^5.0.0\n\n## Boilerplates\n\n- [mmlpx-todomvc](https://github.com/mmlpxjs/mmlpx-todomvc)\n\n## Motivation\n\nTry to explore the possibilities for building a view-framework-free data layer based on mobx, summarize the generic model layer paradigm, and provide the relevant useful toolkits to make it easier and more intuitive.\n\n## Articles\n\n* [Turn On Time-Travelling Engine For MobX](https://itnext.io/turn-on-time-travelling-for-mobx-c3f267a46f10)  ([中文](https://zhuanlan.zhihu.com/p/39354507))\n\n## Features\n\n```ts\nimport { inject, onSnapshot, getSnapshot, applySnapshot } from 'mmlpx'\nimport Store from './Store'\n\n@observer\nclass App extends Component {\n  \n  @inject() store: Store\n  \n  stack: any[]\n  cursor = 0\n  disposer: IReactionDisposer\n  \n  componentDidMount() {\n    this.stack.push(getSnapshot());\n    this.disposer = onSnapshot(snapshot =\u003e {\n      this.stack.push(snapshot)\n      this.cursor = this.stack.length - 1\n      this.store.saveSnapshot(snapshot)\n    })\n  }\n    \n  componentWillUmount() {\n    this.disposer();\n  }\n  \n  redo() {\n    applySnapshot(this.stack[++this.cursor])\n  }\n  \n  undo() {\n    applySnapshot(this.stack[--this.cursor])\n  }\n}\n```\n\n### DI System\n\nIt is well known that MobX is an value-based reactive system which lean to oop paradigm, and we defined our states with a class facade usually. To avoid constructing the instance everytime we used and to enjoy the other benifit (unit test and so on), a [di](https://en.wikipedia.org/wiki/Dependency_injection) system is the spontaneous choice.\n\nmmlpx DI system was deep inspired by [spring ioc](https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/core.html#beans).\n\n#### Typescript Usage\n\n```ts\nimport { inject, ViewModel, Store } from 'mmlpx';\n\n@Store\nclass UserStore {}\n\n@ViewModel\nclass AppViewModel {\n    @inject() userStore: UserStore;\n}\n```\n\nDue to we leverage the metadata description ability of typescript, you need to make sure that you had configured `emitDecoratorMetadata: true`  in your `tsconfig.json`.\n\n#### Javascript Usage\n\n```js\nimport { inject, ViewModel, Store } from 'mmlpx';\n\n@Store\nclass UserStore {}\n\n@ViewModel\nclass AppViewModel {\n    @inject(UserStore) userStore;\n}\n```\n\n#### More Advanced\n\n##### inject\n\nSometimes you may need to intialize your dependencies dynamically, such as the constructor parameters came from router query string. Fortunately `mmlpx` supported the ability via `inject`.\n\n```js\nimport { inject, ViewModel } from 'mmlpx'\n\n@ViewModel\nclass ViewModel {\n    @observable.ref\n    user = {};\n    \n    constructor(projectId, userId) {\n        this.projectId = projectId;\n        this.userId = userId;\n    }\n    \n    loadUser() {\n        this.user = this.http.get(`/projects/${projectId}/users/${userId}`);\n    }\n}\n\nclass App extends Component {\n    @inject(ViewModel, app =\u003e [app.props.params.projectId, app.props.params.userId])\n    viewModel;\n    \n    componentDidMount() {\n        this.viewModel.loadUser();\n    }\n}\n```\n\n`inject` decorator support four recipes initilizaztion:\n\n* `inject() viewModel: ViewModel;` only for typescript.\n* `inject(ViewModel) viewModel;` generic usage.\n* `inject(ViewModel, 10, 'kuitos') viewModel;`  initialized with static parameters for `ViewModel` constrcutor.\n* `inject(ViewModel, instance =\u003e instance.router.props) viewModel;` initialized with dynamic instance props for `ViewModel` constructor.\n\n**Notice that all the `Store` decorated classes are singleton by default so that the dynamic initial params injection would be ignored by di system**, if you wanna make your state live around the component lifecycle, always decorated them with `ViewModel` decorator.\n\n##### instantiate\n\nWhile you are limited to use `decorator` in some scenario, you could use `instantiate` to instead of `@inject`.\n\n```ts\n@ViewModel\nclass UserViewModel {\n    constructor(name, age) {\n        this.name = name;\n        this.age = age;\n    }\n}\n\nconst userVM = instantiate(UserViewModel, 'kuitos', 18);\n```\n\n#### Test Support\n\n`mmlpx` di system also provided the mock method to support unit test.\n\n* `function mock\u003cT\u003e(Clazz: IMmlpx\u003cT\u003e, mockInstance: T, name?: string) : recover`\n\n```js\n@Store\nclass InjectedStore {\n    name = 'kuitos';\n}\n\nclass ViewModel {\n    @inject() store: InjectedStore;\n}\n\n// mock the InjectedStore\nconst recover = mock(InjectedStore, { name: 'mock'});\n\nconst vm = new ViewModel();\nexpect(vm.store.name).toBe('mock');\n// recover the di system\nrecover();\n\nconst vm2 = new ViewModel();\nexpect(vm2.store.name).toBe('kuitos');\n```\n\n### Strict Mode\n\nIf you wanna strictly follow the CQRS paradigm to make your state changes more predictable, you could enable the strict mode by invoking `useStrcit(true)`, then your actions in `Store` or `ViewModel` will throw an exception while you declaring a return statement.\n\n```ts\nimport { useStrict } from 'mmlpx';\nuseStrict(true);\n\n@Store\nclass UserStore {\n    @observable name = 'kuitos';\n    \n    @action updateName(newName: string) {\n        this.name = newName;\n        // return statement will throw a exceptin when strict mode enabled\n        return this.name;\n    }   \n}\n```\n\n### Time Travelling\n\n\u003cdiv align=\"center\"\u003e\n   \u003cimg src=\"https://github.com/mmlpxjs/mmlpx-todomvc/blob/master/todomvc.gif?raw=true\"\u003e\n\u003c/div\u003e\n\nBenefit from the power of model management by di system, mmlpx supported time travelling out of box.\n\nAll you need are the three apis: `getSnapshot`, `applySnapshot` and `onSnapshot`.\n\n* `function getSnapshot(injector?: Injector): Snapshot;`\n\n  `function getSnapshot(modelName: string, injector?: Injector): Snapshot;`\n\n* `function applySnapshot(snapshot: Snapshot, injector?: Injector): void;`\n\n* `function onSnapshot(onChange: (snapshot: Snapshot) =\u003e void, injector?: Injector): IReactionDisposer;`\n  `function onSnapshot(modelName: string, onChange: (snapshot: Snapshot) =\u003e void, injector?: Injector): IReactionDisposer;`\n\nThat's to say, mmlpx makes mobx do [HMR](https://github.com/mmlpxjs/mmlpx/blob/master/src/api/makeHot.ts) and [SSR](https://ssr.vuejs.org/#what-is-server-side-rendering-ssr) possible as well!\n\nAs we need to serialize the stores to persistent object, and active stores with deserialized json, we should give a name to our `Store`:\n\n```ts\n@Store('UserStore')\nclass UserStore {}\n```\n\nFortunately mmlpx had provided [ts-plugin-mmlpx](https://github.com/mmlpxjs/ts-plugin-mmlpx) to generate store name automatically, you don't need to name your stores manually.\n\nYou can check the [mmlpx-todomvc redo/undo demo](https://mmlpxjs.github.io/mmlpx-todomvc) and the [demo source code](https://github.com/mmlpxjs/mmlpx-todomvc/blob/master/src/containers/TodoApp/ViewModel.ts#L124) for details.\n\n## Layered Architecture Overview\n\n\u003cdiv align=\"center\"\u003e\n   \u003cimg src=\"https://github.com/mmlpxjs/mmlpx/blob/gh-pages/assets/mmlpx.png?raw=true\"\u003e\n\u003c/div\u003e\n\n### Store\n\nBusiness logic and rules definition, equate to the model in [mvvm architecture](https://msdn.microsoft.com/en-us/library/hh848246.aspx), singleton in an application. Also known as domain object in [DDD](https://en.wikipedia.org/wiki/Domain-driven_design), always represent the single source of truth of the application.\n\n```ts\nimport { observable, action, observe } from 'mobx';\nimport { Store, inject } from 'mmlpx';\nimport UserLoader from './UserLoader';\n\n@Store\nclass UserStore {\n    \n    @inject() loader: UserLoader;\n    \n    @observable users: User[];\n    \n    @action\n    async loadUsers() {\n        const users = await this.loader.getUsers();\n        this.users = users;\n    }\n    \n    @postConstruct\n    onInit() {\n        observe(this, 'users', () =\u003e {})\n    }\n}\n```\n\n*Method decorated by `postConstruct` will be invoked when `Store` initialized by DI system.*\n\n### ViewModel\n\nPage interaction logic definition, live around the component lifecycle,  `ViewModel` instance can not be stored in ioc container. \n\nThe only direct consumer of `Store`, besides the UI-domain/local states, others are derived from `Store` via `@computed` in `ViewModel`. \n\nThe global states mutation are resulted by store **command** invocation in `ViewModel`, and the separated **queries** are represented by transparent subscriptions with `computed` decorator.\n\n```ts\nimport { observable, action } from 'mobx';\nimport { postConstruct, ViewModel, inject } from 'mmlpx';\n\n@ViewModel\nclass AppViewModel {\n    \n    @inject() userStore: UserStore;\n    \n    @observable loading = true;\n    \n    @computed\n    get userNames() {\n        return this.userStore.users.map(user =\u003e user.name);\n    }\n    \n    @action\n    setLoading(loading: boolean) {\n        this.loading = loading;\n    }   \n}\n```\n\n### Loader\n\nData accessor for remote or local data fetching, converting the data structure to match definited models.\n\n```ts\nclass UserLoader {\n    async getUsers() {\n        const users = await this.http.get\u003cUser[]\u003e('/users');\n        return users.map(user =\u003e ({\n            name: user.userName,\n            age: user.userAge,\n        }))\n    }\n}\n```\n\n### Component\n\n```jsx\nexport default App extends Component {\n    \n    @inject()\n    vm: AppViewModel;\n    \n    render() {\n        const { loading, userName } = this.vm;\n        return (\n            \u003cdiv\u003e\n                {loading ? \u003cLoading/\u003e : \u003cp\u003e{userName}\u003c/p\u003e} \n            \u003c/div\u003e\n        );\n    }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmlpxjs%2Fmmlpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmlpxjs%2Fmmlpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmlpxjs%2Fmmlpx/lists"}