与先前的值相比,此运算符将提供可观察到的来自源的所有值。
语法
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,如若转载,请注明出处:https://www.web176.com/rxjs/1865.html
支付宝
微信