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

Chats store

This store is responsible for holding all the data and logic surrounding chats and messages, but it also helps the chats store initializing when a user is logged in:

/*** src/stores/chats.js ***/import { observable, computed, map, toJS, action } from 'mobx'; import { AsyncStorage } from 'react-native' import { firebaseApp } from '../firebase' import notifications from '../notifications' class Chats { @observable list; @observable selectedChatMessages; @observable downloadingChats = false; @observable downloadingChat = false; @action addMessages = function(chatId, contactId, messages) { //add a list of messages to a chat } @action selectChat = function(id) { //set a chat as selected and retrieve all the messages for it } @action ...

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