Skip to content

Instantly share code, notes, and snippets.

@inklesspen
Last active August 29, 2015 14:26
Show Gist options
  • Save inklesspen/a99365cf23c3e823a4d5 to your computer and use it in GitHub Desktop.
Save inklesspen/a99365cf23c3e823a4d5 to your computer and use it in GitHub Desktop.
var LocationSource = {
fetchLocations(country) {
return {
remote() {
// return a promise fetching locations for the given country
return new Promise(/* do stuff here */).then(
function(response) {
return [country, response]
},
function(error) {
return [country, error]
})
},
local() {
// Never check locally, always fetch remotely.
return null;
},
success: LocationActions.updateLocations,
error: LocationActions.locationsFailed,
loading: LocationActions.fetchLocations
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment