Created
January 3, 2017 20:42
-
-
Save MiguelLattuada/6a060bc9c987d2c8d54f0e158717d2e3 to your computer and use it in GitHub Desktop.
RxJS 5 wrapper for Promise.all method.
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
class ApiRequest { | |
all(requests) { | |
return Rx.Observable.forkJoin(...requests); | |
} | |
... | |
} | |
var apiRequest = new ApiRequest(); | |
apiRequest | |
.all([apiRequest.observableRequest('http://pokeapi.co/api/v2/pokemon/1'), apiRequest.observableRequest('http://pokeapi.co/api/v2/pokemon/2'), apiRequest.observableRequest('http://pokeapi.co/api/v2/pokemon/3')]) | |
.subscribe(responses => console.log(responses)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment