Last active
August 29, 2015 14:26
-
-
Save inklesspen/a99365cf23c3e823a4d5 to your computer and use it in GitHub Desktop.
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
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