- MobX Quick Start Guide
- Pavan Podila Michel Weststrate
- 122字
- 2021-08-05 10:34:21
An observable state
The state is at the epicenter of all things happening in the UI. MobX provides a core building block, called the observable, that represents the reactive state of your application. Any JavaScript object can be used to create an observable. We can use the aptly named observable() API as follows:
import {observable} from 'mobx';
let cart = observable({
itemCount: 0,
modified: new Date()
});
In the preceding example, we have created a simple cart object that is also an observable. The observable() API comes from the mobx NPM package. With this simple declaration of an observable, we now have a reactive cart that keeps track of changes happening on any of its properties: itemCount and modified.
推薦閱讀
- Building E-commerce Sites with VirtueMart Cookbook
- Force.com Development Blueprints
- 互聯網基礎資源技術與應用發展態勢(2021—2023)
- Windows Server 2012 Hyper-V虛擬化管理實踐
- 6G無線網絡空口關鍵技術
- Learning Node.js Development
- Professional Scala
- 信息技術安全評估準則:源流、方法與實踐
- 黑客與反黑工具使用詳解
- INSTANT Social Media Marketing with HootSuite
- Microservices Development Cookbook
- 智慧的物聯網:感知中國和世界的技術
- 網絡分析技術揭秘:原理、實踐與WinPcap深入解析
- Twilio Cookbook(Second Edition)
- Mastering Prezi for Business Presentations