Skip to Content
React Native Blueprints
book

React Native Blueprints

by Emilio Rodriguez Martinez
November 2017
Intermediate to advanced content levelIntermediate to advanced
346 pages
7h 33m
English
Packt Publishing
Content preview from React Native Blueprints

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical React Native: Build Two Full Projects and One Full Game using React Native

Practical React Native: Build Two Full Projects and One Full Game using React Native

Frank Zammetti
Mastering React Native

Mastering React Native

Eric Masiello, Jacob Friedmann

Publisher Resources

ISBN: 9781787288096Supplemental Content