A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://reactivex.io/documentation/operators/sequenceequal.html below:

ReactiveX - SequenceEqual operator

  1. Operators
  2. Conditional and Boolean
  3. SequenceEqual
SequenceEqual determine whether two Observables emit the same sequence of items

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 are the same (the same items, in the same order, with the same termination state).

See Also Language-Specific Information:

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.

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.

This operator does not by default operate on any particular Scheduler.

In RxJS, sequenceEqual is a method of a particular Observable instance, so you pass it exactly one other Observable to compare the instance to. You can optionally pass a second parameter: a function that accepts two items and returns true if they are equal according to a standard of your choosing. sequenceEqual returns an Observable that will emit a true if the two Observables emit the same set of items in the same order before completing, or a false otherwise.

Sample Code
var source1 = Rx.Observable.return(42);
var source2 = Rx.Observable.return(42);

var source = source1.sequenceEqual(source2);

var subscription = source.subscribe(
    function (x) { console.log('Next: ' + x); },
    function (err) { console.log('Error: ' + err); },
    function () { console.log('Completed'); });
Next: true
Completed

sequenceEqual is found in each of the following distributions:

sequenceEqual requires one of the following distributions:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4