Last active
April 14, 2017 13:46
-
-
Save ben-barbier/18dfe6e6e12d65a87963052a2ce1f385 to your computer and use it in GitHub Desktop.
rx - how to chain calls ?
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
import {Component} from '@angular/core'; | |
import {Team} from '../../../models/team'; | |
import {Sprint} from '../../../models/sprint'; | |
import {Observable} from 'rxjs/Observable'; | |
import {Http, Response} from '@angular/http'; | |
@Component({ | |
selector: 'app-test-backlog-agile', | |
templateUrl: './test-backlog-agile.component.html', | |
styleUrls: ['./test-backlog-agile.component.scss'] | |
}) | |
export class TestBacklogAgileComponent { | |
teams: Team[] = []; | |
constructor(private http: Http) { | |
this.http.get('/data/teams.json') | |
.flatMap((response: Response) => response.json()) | |
.filter((team: Team) => team.agile === true) | |
.flatMap((team: Team) => // équivalent du resolve !!!!! | |
this.http.get('/data/sprint.json') // URL paramétrée | |
.map((response: Response) => response.json()) | |
.map((sprint: Sprint) => { | |
team.actualSprint = sprint; | |
return team; | |
}) | |
) | |
.reduce((teams, team) => { | |
teams.push(team); | |
return teams; | |
}, []) | |
// .bufferCount(Infinity) | |
.subscribe(teams => { | |
this.teams= teams; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment