The store

MobX uses the concept of "observable" properties. We should declare an object containing our general application's state, which will hold and declare those observable properties. When we modify one of these properties, all the subscribed observers will be updated by MobX automatically. This is the basic principle behind MobX, so let's take a look at a sample code:

/*** src/store.js ***/import {observable} from 'mobx';class Store { @observable feeds; ... constructor() {   this.feeds = []; } addFeed(url, feed) {   this.feeds.push({      url,      entry: feed.entry,     title: feed.title,     updated: feed.updated   });   this._persistFeeds(); } ...}const store = new Store()export default store

We have an attribute, feeds, marked as @observable, meaning that ...

Get React Native Blueprints now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.