Skip to content

Instantly share code, notes, and snippets.

@MiguelLattuada
Created January 3, 2017 20:42
Show Gist options
  • Save MiguelLattuada/6a060bc9c987d2c8d54f0e158717d2e3 to your computer and use it in GitHub Desktop.
Save MiguelLattuada/6a060bc9c987d2c8d54f0e158717d2e3 to your computer and use it in GitHub Desktop.
RxJS 5 wrapper for Promise.all method.
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