I use forkjoin to initialize data before loading my page. Unfortunately I have reached the limit of 6 parameters for forkjoin:
export class Sample implements OnInit {
list1?: Pair[];
list2?: Pair[];
list3?: Pair[];
list4?: Pair[];
list5?: PairExt[];
list6?: PairExt[];
list7?: PairExt[];
constructor(private http: HttpService,
private httpWithCaching: HttpWithCachingService) {
}
ngOnInit(): void {
this.initLists().subscribe(([list1, list2, list3, list4, list5, list6, list7]) => {
this.list1 = list1;
this.list2 = list2;
this.list3 = list3;
this.list4 = list4;
this.list5 = list5;
this.list6 = list6;
this.list7 = list7;
this.initModule();
});
}
initLists(): Observable<[Pair[], Pair[], Pair[], Pair[], PairExt[], PairExt[], PairExt[]]> {
return forkJoin([
this.httpWithCaching.getList1(),
this.httpWithCaching.getList2(),
this.httpWithCaching.getList3(),
this.httpWithCaching.getList4(),
this.httpWithCaching.getList5(),
this.httpWithCaching.getList6(),
this.httpWithCaching.getList7()
]);
}
initModule(): void {
//some requests and initialization after the lists were fetched...
}
The code above will therefore no longer work as forkjoin is lmited to 6 parameters.
What would be the most simple solution for my case? All I want to do really is to fetch the lists before calling my initModule
...
Thanks in advance!