Pass sequenceEqual
two Observables, and it will compare the items emitted by each Observable, and the Observable it returns will emit true
only if both sequences terminate normally after emitting the same sequence of items in the same order; otherwise it will emit false
. You can optionally pass a third parameter: a function that accepts two items and returns true
if they are equal according to a standard of your choosing.
Sample Code
def firstfour = Observable.from([1, 2, 3, 4]);
def firstfouragain = Observable.from([1, 2, 3, 4]);
def firstfive = Observable.from([1, 2, 3, 4, 5]);
def firstfourscrambled = Observable.from([3, 2, 1, 4]);
println('firstfour == firstfive?');
Observable.sequenceEqual(firstfour, firstfive).subscribe({ println(it); });
println('firstfour == firstfouragain?');
Observable.sequenceEqual(firstfour, firstfouragain).subscribe({ println(it); });
println('firstfour == firstfourscrambled?');
Observable.sequenceEqual(firstfour, firstfourscrambled).subscribe({ println(it); });
firstfour == firstfive?
false
firstfour == firstfouragain?
true
firstfour == firstfourscrambled?
false
This operator does not by default operate on any particular Scheduler.