Created
April 17, 2015 04:12
-
-
Save jsheely/f652928458dadc07ba9c 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 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