This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Button, Text, SafeAreaView } from 'react-native'; | |
import { observable } from 'mobx'; | |
import { observer } from 'mobx-react'; | |
const store = observable({ count: 0 }); | |
const LoginScreen = observer(() => { | |
handleInc = () => store.count++; | |
handleDesc = () => store.count--; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Button, Text, SafeAreaView } from 'react-native'; | |
import { observable } from 'mobx'; | |
import { observer } from 'mobx-react'; | |
@observer export class LoginScreen extends React.Component { | |
@observable count = 0; | |
handleInc = () => this.count++; | |
handleDesc = () => this.count--; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": ["mobx"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { AppRegistry } from 'react-native'; | |
import { StatusBar } from 'react-native'; | |
import { name as appName } from './app.json'; | |
import AppNavigator from 'containers/AppNavigator'; | |
import { createAppContainer } from 'react-navigation'; | |
import { store } from 'store'; | |
import { Provider } from 'react-redux'; | |
import { PersistGate } from 'redux-persist/integration/react' | |
import { persistor } from 'store'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { AppRegistry } from 'react-native'; | |
import { StatusBar } from 'react-native'; | |
import { name as appName } from './app.json'; | |
import AppNavigator from 'containers/AppNavigator'; | |
import { createAppContainer } from 'react-navigation'; | |
import { store } from 'store'; | |
import { Provider } from 'react-redux'; | |
StatusBar.setBarStyle('light-content', true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from 'react'; | |
import { View, Text, TouchableOpacity, Image, FlatList, StyleSheet, RefreshControl } from 'react-native'; | |
import images from 'res/images'; | |
import colors from 'res/colors'; | |
import palette from 'res/palette'; | |
import MessageListItem from './MessageListItem'; | |
import SearchBar from './SearchBar'; | |
import { connect } from 'react-redux'; | |
import { loadMessages } from 'actions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { put, fork, select, all, take, call } from 'redux-saga/effects' | |
import { getMessages } from 'reducers/selectors' | |
import { api } from 'services' | |
import { messages, LOAD_MESSAGES } from 'actions' | |
function* fetchEntity(entity, apiFn, id) { | |
yield put( entity.request(id) ) | |
const {response, error} = yield call(apiFn, id) | |
if(response) | |
yield put( entity.success(id, response) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore, applyMiddleware } from 'redux'; | |
import rootReducer from 'reducers'; | |
import logger from 'redux-logger'; | |
import createSagaMiddleware from 'redux-saga'; | |
import rootSaga from 'sagas'; | |
const sagaMiddleware = createSagaMiddleware(); | |
sagaMiddleware.run(rootSaga); | |
export const store = createStore(rootReducer, applyMiddleware(sagaMiddleware, logger)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers } from 'redux' | |
import { merge } from 'lodash/object' | |
function entities(state = { messages: {} }, action) { | |
if (action.response && action.response.entities) { | |
return merge({}, state, action.response.entities) | |
} | |
return state | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { schema } from 'normalizr' | |
const messageSchema = new schema.Entity('messages', {}, { | |
idAttribute: 'key', | |
}); | |
export const responseMessageSchema = { messages: new schema.Array(messageSchema) }; |