Skip to content

Instantly share code, notes, and snippets.

@jsheely
Created April 17, 2015 04:12
Show Gist options
  • Save jsheely/f652928458dadc07ba9c to your computer and use it in GitHub Desktop.
Save jsheely/f652928458dadc07ba9c to your computer and use it in GitHub Desktop.
var people = [{
name: 'Jon',
location: 'New York, NY'
}, {
name: 'Joe',
location: null
}, {
name: 'Tom',
location: 'San Francisco, CA'
}];
var source = Rx.Observable.from(people);
var updateLocations = source.filter(function(p) {
return p.location != null
}).flatMap(function(p) {
return Rx.Observable.fromPromise(geocoder.geocode(p.location).then(function(result) {
p.location = result;
console.log('I ran', result);
}));
});
var updateName = source
.filter(function(p){
return p.name.indexOf('J')===0;
})
.map(function(p){
p.name = p.name + ' Awesome';
return p;
});
//Subscribe to something that gives me the final list of items all merged together
//I need to be able to throttle the geocoder requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment