Created
January 10, 2018 12:26
-
-
Save LironHazan/2a1905d59fb729a50798d121bc099bc7 to your computer and use it in GitHub Desktop.
I needed to do something similar to the promise.all just with observables and came up with forkJoin, here's an example
This file contains hidden or 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
geSomethingById(id: number): Observable<any[]> { | |
return this.http.get<any[]>( | |
`api/something?id=${id}`); | |
} | |
getSomething(ids) { | |
const ids = this.getListOfVersionIds(selectedArtifacts) | |
const requests = ids.reduce((acc, id) => { | |
acc.push(this.geSomethingById(id)); | |
return acc; | |
}, []); | |
return forkJoin(requests) | |
.subscribe((files) => { | |
return files; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment