Created
October 13, 2018 09:44
-
-
Save Mulperi/a71fddf44965ef8714ace9263fbba926 to your computer and use it in GitHub Desktop.
Observable concatMap
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
const { from } = require('rxjs'); | |
const { concatMap } = require('rxjs/operators'); | |
const getUserId = () => { | |
return from(['1337']); | |
}; | |
const getUserById = id => { | |
return from([ | |
{ | |
id: '1337', | |
name: 'mika' | |
} | |
]); | |
}; | |
const apiRequest = getUserId().pipe( | |
concatMap(userid => { | |
console.log(userid); | |
return getUserById(userid); | |
}) | |
); | |
apiRequest.subscribe( | |
data => console.log(data), | |
error => console.log(error), | |
() => console.log('complete') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment