O'Reilly logo

Reactive Programming with Swift 4 by Navdeep Singh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The distinctUntilChanged operator

The distinctUntilChanged() operator is also widely used. This operator will only allow unique contiguous elements to pass through; in other words, if the next element is equal to the previous one, it will not be allowed through:

>

This can be used with search logic to prevent executing a search twice in a row on the same search string or even on an insert statement where you want to add the login status to the local storage, and you don't want to save the same state more than once if it is the same.

Let's see the operator in action; we need to create a similar bare-bones function implementation with a disposeBag ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required