Reputation: 2364
I am trying to build a test case that checks if two streams are the same. Zip can be used to check the value elements are the same, but it doesn't help if one stream is the wrong length. Any ideas on how to approach this?
Upvotes: 1
Views: 556
Reputation: 17430
There's an operator for that: sequenceEqual.
Returns
(Observable): An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.
Here's a simple example showing the length equality check.
var log = console.log.bind(console);
Rx.Observable.of(1, 2, 3)
.sequenceEqual(Rx.Observable.of(1, 2, 3))
.subscribe(log); // logs true
Rx.Observable.of(1, 2, 3)
.sequenceEqual(Rx.Observable.of(1, 2))
.subscribe(log); // logs false
Upvotes: 3