Created
December 8, 2016 21:26
-
-
Save ashish173/001ee38c698883b9f59d5be005c6ae29 to your computer and use it in GitHub Desktop.
Map operator
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
//emit (1,2,3,4,5) | |
const source = Rx.Observable.from([1,2,3,4,5]); | |
//add 10 to each value | |
const example = source.map(val => val + 10); | |
//output: 11,12,13,14,15 | |
const subscribe = example.subscribe(val => console.log(val)); | |
//emit ({name: 'Joe', age: 30}, {name: 'Frank', age: 20},{name: 'Ryan', age: 50}) | |
const sourceTwo = Rx.Observable.from([{name: 'Joe', age: 30}, {name: 'Frank', age: 20},{name: 'Ryan', age: 50}]); | |
//grab each persons name | |
const exampleTwo = sourceTwo.map(person => person.name); | |
//output: "Joe","Frank","Ryan" | |
const subscribe = exampleTwo.subscribe(val => console.log(val)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment