Shawn McKay
Real time sensor data/graphs.
Make field notes.
displaying the connection
lazy / eager loading
persistant data
handling large files
read / write responses
a better solution
503 - Server error
import { View, StatusBar } from 'react-native';
import OfflineBanner from './OfflineBanner';
const Page = ({ children, style }) => (
<View style={[styles.navContentView, style]}>
<StatusBar
backgroundColor="transparent"
translucent barStyle="light-content"
/>
<OfflineBanner />
{React.Children.toArray(children)}
</View>
)
const OfflineBanner = ({ netInfo }) => { return ( netInfo === 'none' ? <Code /> : null; ); }; const mapState = state => ({ netInfo: state.netInfo, }); export default connect(mapState)(NetInfo);
Not as easy...
const async = () => (dispatch) => {
dispatch({ type: 'PENDING' })
fetch(someURL)
.then((data) => dispatch({ type: 'SUCCESS' }))
.catch((e) => dispatch({ type: 'FAILURE' }))
}
Time
const decaySchedule = [
1000, //After 1 seconds
1000 * 5, //After 5 seconds
1000 * 15, //After 15 seconds
1000 * 30, //After 30 seconds
1000 * 60, //After 1 minute
1000 * 60 * 3, //After 3 minutes
1000 * 60 * 5, //After 5 minutes
1000 * 60 * 10, //After 10 minutes
1000 * 60 * 30, //After 30 minutes
1000 * 60 * 60 //After 1 hour ];
export default (action, retries): => decaySchedule[retries];
const config = {
retry: (action, retries) =>
action.meta.urgent
? 100
: 1000 * (retries + 1)
}
const async = () => (dispatch, getState) => {
dispatch({ type: 'LOADING' })
fetch(someURL)
.then((data) => dispatch({ type: 'SUCCESS' }))
.catch((e) => dispatch({ type: 'FAILURE' }))
}
const asyncAction = () => ({
type: 'LOADING',
meta: {
offline: {
effect: { url: someURL },
commit: { type: 'SUCCESS' },
rollback: { type: 'FAILURE' },
}
}
})
const asyncAction = (id) => ({
type: 'LOADING',
meta: {
offline: {
effect: { url: `${someURL}/${id}` },
commit: { type: 'SUCCESS', payload: { id }},
rollback: { type: 'FAILURE', payload: { id } },
}
}
})
const asyncAction = (id) => ({
type: 'LOADING',
meta: {
offline: {
effect: { url: `${someURL}/${id}` },
commit: () => (dispatch) => dispatch(success()),
rollback: { type: 'FAILURE', payload: { id } },
}
}
})
Average Programmer
Awesome Programmer
@Sh_McK
shawn.j.mckay@gmail.com