Operator distinct() and its variants are an important type of Filtering operator. This lessons shows how they work and in what cases are they useful.
🚨 Since we are importing interval
from RxJS, we don't need to preface our Observables with Rx.Observable
. You can no longer .{operator}
, you need to .pipe({operator})
instead.
For people using TypeScript, you have have to import 'rxjs/add/operator/distinct'; Distinct was not included when importing 'rxjs/Rx'; and my build was erroring out.
var result = foo.distinct((x,y) => x.toLowerCase() === y.toLowerCase());
gives: "error: TypeError: y is undefined"
Should be:
var result = foo.distinct((x) => x.toLowerCase());
Hi Mike. That's correct. We should update the lesson to use a 'keySelector' function, not a 'compare' function.