Categories: RxJS教程

RxJS:过滤运算符distinct

与先前的值相比,此运算符将提供可观察到的来自源的所有值。

语法

distinct()

返回值

它返回一个具有不同值的observable。

import { of } from 'rxjs';
import { distinct } from 'rxjs/operators';

let all_nums = of(1, 6, 15, 1, 10, 6, 40, 10, 58, 20, 40);
let final_val = all_nums.pipe(distinct());
final_val.subscribe(x => console.log("The Distinct values are "+x));

输出

terry

这个人很懒,什么都没有留下~

Share
Published by
terry

Recent Posts