在Angular 6中不推荐使用zip: tslint给我以下消息:
zip is deprecated: resultSelector is no longer supported, pipe to map instead
我如何升级以下代码:
import {interval, from, zip} from 'rxjs';
let testArray = [1, 2, 3, 4, 5];
array$ = from(testArray);
inter$ = interval(1000);
numbersOverTime$ = zip(array$, inter$, (item, i) => item);
答案 0 :(得分:2)
只需通过管道zip
和map
:
numbersOverTime$ = zip(array$, inter$)
.pipe(
map(([item, i]) => item)
);