- 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.
推薦閱讀
- 通信網(wǎng)絡(luò)基礎(chǔ)與設(shè)備
- 物聯(lián)網(wǎng)工程規(guī)劃技術(shù)
- 物聯(lián)網(wǎng)安全:理論、實踐與創(chuàng)新
- 萬物互聯(lián):蜂窩物聯(lián)網(wǎng)組網(wǎng)技術(shù)詳解
- 信息通信網(wǎng)絡(luò)建設(shè)安全管理概要2
- Building RESTful Web Services with Spring 5(Second Edition)
- Spring 5.0 Projects
- VMware NSX網(wǎng)絡(luò)虛擬化入門
- Echo Quick Start Guide
- 網(wǎng)管第一課:網(wǎng)絡(luò)操作系統(tǒng)與配置管理
- 圖神經(jīng)網(wǎng)絡(luò)前沿
- Hands-On Docker for Microservices with Python
- Web用戶查詢?nèi)罩就诰蚺c應(yīng)用
- Professional Scala
- 智慧城市中的物聯(lián)網(wǎng)技術(shù)