Skip to content

Commit

Permalink
Simulate error cases 50% of the time to have a great demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Napoli committed Aug 13, 2018
1 parent 739d3cd commit b7d4598
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion App/Containers/HomeScreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Platform, StyleSheet, Text, View } from 'react-native'
import { Platform, StyleSheet, Text, View, Button } from 'react-native'
import { connect } from 'react-redux'
import { PropTypes } from 'prop-types'
import ExampleActions from 'App/Stores/Example/Actions'
Expand All @@ -24,6 +24,7 @@ class HomeScreen extends React.Component {
The weather temperature is: {this.props.temperature}
</Text>
<Text style={styles.instructions}>{this.props.errorMessage}</Text>
<Button onPress={this.props.fetchTemperature} title="Refresh"/>
</View>
)
}
Expand Down
7 changes: 7 additions & 0 deletions App/Service/WeatherService.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ const weatherApiClient = create({
})

function fetchTemperature() {
// Simulate an error 50% of the time just for testing purposes
if (Math.random() > 0.5) {
return new Promise(function(resolve, reject) {
resolve(null);
});
}

const locationQuery = escape(
"select item.condition.temp from weather.forecast where woeid in (select woeid from geo.places where text='Lyon, Rhone-Alpes, FR') and u='c'"
)
Expand Down

0 comments on commit b7d4598

Please sign in to comment.