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]};
})
}
);

Rxjs ForkJoin的使用

上一篇:每一个JavaScript开发者应该了解的浮点知识


下一篇:CSS 用户界面样式