Skip to content
项目

关于

A collection of simple mobx examples

学习与教育

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

MobX Examples

Modern MobX 6 examples using TypeScript and Vite. Each example is a self-contained project that can be opened directly in CodeSandbox.

Examples

# Example Concepts Open
01 Observable & Autorun makeAutoObservable, autorun, dependency tracking CodeSandbox
02 Computed computed getters, caching, lazy evaluation CodeSandbox
03 Actions configure({ enforceActions }), action, batching CodeSandbox
04 runInAction runInAction, async patterns CodeSandbox
05 Reaction reaction, data vs effect functions, disposal CodeSandbox
06 When when callback + promise form CodeSandbox
07 Observable Map observable.map, dynamic keys CodeSandbox
08 Observable Array Observable arrays, proxy behavior CodeSandbox
09 React Todo observer, mobx-react-lite, store + React Context CodeSandbox
10 React Timer observer, computed, interval side effects CodeSandbox

Running locally

Each example is a standalone Vite project:

cd examples/01-observable-autorun
npm install
npm run dev

MobX 3 to 6 migration reference

MobX 3 (old) MobX 6 (new)
mobx.observable({...}) + factory functions class + makeAutoObservable(this)
mobx.extendObservable(this, {...}) makeAutoObservable(this)
mobx.useStrict(true) configure({ enforceActions: "always" })
mobx.whyRun() Removed
React.createClass + mobxReact.observer() observer(FunctionComponent) from mobx-react-lite
mobxReact.Provider + inject() React Context + useContext()

License

MIT

探索相关项目

加载中…