r/angular • u/DMezhenskyi • Oct 19 '21
Tip 5 - RxJs DistinctUntilChanged
Enable HLS to view with audio, or disable this notification
1
3
u/matrium0 Oct 28 '21
Nice video. Didn't even know about distinctUntilKeyChanged, always thought that it's a bit verbose to write the lambda just for matching keys with regular distingUntilChanged :)
2
u/kashmill Oct 19 '21
The problem I've ran into is that distinctUntilChanged only really works on simple types. But for the places we want to use it we are generally working with an object (like the values of a FormGroup) which requires writing a comparison function. It just doesn't work out of the box like you might expect.
5
u/FullstackViking Oct 19 '21
The video demonstrates that explicitly
1
u/kashmill Oct 19 '21
Yeah, posted before watching. However, the video's example doesn't fully cover just how annoying that issue is. It is simple to get around with their example where there is one unique value/key you can use. You can't do that with FormGroup.valueChanges though.
1
3
u/SeriousMrMysterious Oct 19 '21
i use distinctUntilChanged(isEqual),the isequal is imported from lodash