Skip to content

Commit

Permalink
Splitting forkjoin into two
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaknarfen committed Dec 12, 2018
1 parent d8d86c7 commit b94e594
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
10 changes: 8 additions & 2 deletions src/app/core/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ export class DataService {
loadData(gene: Gene): Observable<any[]> {
const genesResponse = this.apiService.getGenes();
const nodesResponse = this.apiService.getLinksList(gene);

return forkJoin([
genesResponse,
nodesResponse
]);
}

loadTissuesModels(): Observable<any[]> {
const tissuesResponse = this.apiService.getGeneTissues();
const modelsResponse = this.apiService.getGeneModels();

return forkJoin([
genesResponse,
nodesResponse,
tissuesResponse,
modelsResponse
]);
Expand Down
29 changes: 18 additions & 11 deletions src/app/genes/gene-overview/gene-overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,27 @@ export class GeneOverviewComponent implements OnInit, OnDestroy, AfterContentChe
// Genes response
this.dataService.loadGenes(responseList[0]);
this.forceService.processSelectedNode(responseList[1], this.gene);
this.geneService.loadGeneTissues(responseList[2]);
this.geneService.loadGeneModels(responseList[3]);

if (!this.geneInfo.nominations) {
this.items.splice(0, 1);
}
if (!this.geneInfo.druggability) {
this.items.splice(this.items.length - 1, 1);
}
this.setActiveItem();
this.dataLoaded = true;
}, (error) => {
console.error('Error loading the data!');
return throwError(error); // Angular 6/RxJS 6
}, () => {
this.dataService.loadTissuesModels().subscribe((responseList) => {
this.geneService.loadGeneTissues(responseList[0]);
this.geneService.loadGeneModels(responseList[1]);

if (!this.geneInfo.nominations) {
this.items.splice(0, 1);
}
if (!this.geneInfo.druggability) {
this.items.splice(this.items.length - 1, 1);
}
this.setActiveItem();
}, (error) => {
console.error('Error loading the data!');
return throwError(error); // Angular 6/RxJS 6
}, () => {
this.dataLoaded = true;
});
});
} else {
if (!this.geneInfo.nominations) {
Expand Down
7 changes: 6 additions & 1 deletion src/app/testing/data-service-stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export class DataServiceStub {
loadData(gene: Gene): Observable<any[]> {
return forkJoin([
of([mockGene1, mockGene2]),
of({ items: [mockDataLink1, mockDataLink2] }),
of({ items: [mockDataLink1, mockDataLink2] })
]);
}

loadTissuesModels(): Observable<any[]> {
return forkJoin([
of([mockTissues]),
of([mockModels])
]);
Expand Down

0 comments on commit b94e594

Please sign in to comment.