learnrx
learnrx copied to clipboard
Exercise 41: Autocomplete Box Part 2: Electric Boogaloo and distinctUntilChanged() usage/behavior
For exercise 41, the distinctUntilChanged() function is used to filter out successive repetitive values. However, when I enter a word with repetitive values aa
vs a
I get different results. Is this expected behavior? If yes, then the same function ( distinctUntilChanged()) does not behave the same way in exercise 40 - in that exercise, typing aa
will display a
. Exercise numbers refer to the tutorial found here: http://jhusain.github.io/learnrx/
I believe that the difference in the behavior is because of the different data being checked for distinctness:
In the exercise 40, the data is a single character from an event. This character is then appended to the string being built. The consequence is that appending two identical characters to the string one after another is prevented.
In the exercise 41, the data is the whole string in the input. The consequence is that submitting two identical strings to the search API endpoint one after another is prevented.
The behavior seems to be correct, but the demonstration is a bit unfortunate - the changed context can cause this confusion.