O'Reilly logo

React Native Blueprints by Emilio Rodriguez Martinez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required