Rxjs ForkJoin的使用

const type$ = this.dictionaryService.findByCode('PUNISHMENT_TYPE');
const category$ = this.dictionaryService.findByCode('PUNISHED_CATEGORY');
const all$ = forkJoin([type$, category$]);
let colors = Object.keys(COLOR).length;
all$.subscribe(
result => {
this.types = result[0].dictionaryValues;
this.types.forEach(type=>{
this.punishedType[type.key] = {text: type.value, color: COLOR[type.showOrder % colors]};
});
this.categories = result[1].dictionaryValues;
this.categories.forEach(category=>{
this.punishedCategory[category.key] = {text: category.value, color: COLOR[category.showOrder % colors]};
})
}
);

posted on 2021-07-03 13:59  谦虚好学每一天  阅读(534)  评论(0)    收藏  举报

导航