1
- import { Observable } from '../Observable' ;
2
-
3
- import { OperatorFunction } from '../types' ;
1
+ import { OperatorFunction , ObservableInput } from '../types' ;
4
2
import { operate } from '../util/lift' ;
5
3
import { createOperatorSubscriber } from './OperatorSubscriber' ;
4
+ import { innerFrom } from '../observable/innerFrom' ;
6
5
7
6
/**
8
7
* Compares all values of two observables in sequence using an optional comparator function
@@ -13,7 +12,8 @@ import { createOperatorSubscriber } from './OperatorSubscriber';
13
12
*
14
13
* 
15
14
*
16
- * `sequenceEqual` subscribes to two observables and buffers incoming values from each observable. Whenever either
15
+ * `sequenceEqual` subscribes to source observable and `compareTo` `ObservableInput` (that internally
16
+ * gets converted to an observable) and buffers incoming values from each observable. Whenever either
17
17
* observable emits a value, the value is buffered and the buffers are shifted and compared from the bottom
18
18
* up; If any value pair doesn't match, the returned observable will emit `false` and complete. If one of the
19
19
* observables completes, the operator will wait for the other observable to complete; If the other
@@ -53,14 +53,15 @@ import { createOperatorSubscriber } from './OperatorSubscriber';
53
53
* @see {@link zip }
54
54
* @see {@link withLatestFrom }
55
55
*
56
- * @param {Observable } compareTo The observable sequence to compare the source sequence to.
57
- * @param {function } [comparator] An optional function to compare each value pair
56
+ * @param compareTo The `ObservableInput` sequence to compare the source sequence to.
57
+ * @param comparator An optional function to compare each value pair.
58
+ *
58
59
* @return A function that returns an Observable that emits a single boolean
59
60
* value representing whether or not the values emitted by the source
60
- * Observable and provided Observable were equal in sequence.
61
+ * Observable and provided `ObservableInput` were equal in sequence.
61
62
*/
62
63
export function sequenceEqual < T > (
63
- compareTo : Observable < T > ,
64
+ compareTo : ObservableInput < T > ,
64
65
comparator : ( a : T , b : T ) => boolean = ( a , b ) => a === b
65
66
) : OperatorFunction < T , boolean > {
66
67
return operate ( ( source , subscriber ) => {
@@ -94,7 +95,7 @@ export function sequenceEqual<T>(
94
95
// at the appropriate time.
95
96
complete ? emit ( false ) : selfState . buffer . push ( a ) ;
96
97
} else {
97
- // If the other stream *does* have values in it's buffer,
98
+ // If the other stream *does* have values in its buffer,
98
99
// pull the oldest one off so we can compare it to what we
99
100
// just got. If it wasn't a match, emit `false` and complete.
100
101
! comparator ( a , buffer . shift ( ) ! ) && emit ( false ) ;
@@ -119,7 +120,7 @@ export function sequenceEqual<T>(
119
120
120
121
// Subscribe to each source.
121
122
source . subscribe ( createSubscriber ( aState , bState ) ) ;
122
- compareTo . subscribe ( createSubscriber ( bState , aState ) ) ;
123
+ innerFrom ( compareTo ) . subscribe ( createSubscriber ( bState , aState ) ) ;
123
124
} ) ;
124
125
}
125
126
0 commit comments