1
1
import { Observable } from '../Observable' ;
2
- import { OperatorFunction } from '../types' ;
2
+ import { OperatorFunction , ObservableInput } from '../types' ;
3
3
import { Subject } from '../Subject' ;
4
4
import { operate } from '../util/lift' ;
5
5
import { createOperatorSubscriber } from './OperatorSubscriber' ;
6
6
import { noop } from '../util/noop' ;
7
+ import { innerFrom } from '../observable/innerFrom' ;
7
8
8
9
/**
9
10
* Branch out the source Observable values as a nested Observable whenever
@@ -17,8 +18,9 @@ import { noop } from '../util/noop';
17
18
* Returns an Observable that emits windows of items it collects from the source
18
19
* Observable. The output Observable emits connected, non-overlapping
19
20
* windows. It emits the current window and opens a new one whenever the
20
- * Observable `windowBoundaries` emits an item. Because each window is an
21
- * Observable, the output is a higher-order Observable.
21
+ * `windowBoundaries` emits an item. `windowBoundaries` can be any type that
22
+ * `ObservableInput` accepts. It internally gets converted to an Observable.
23
+ * Because each window is an Observable, the output is a higher-order Observable.
22
24
*
23
25
* ## Example
24
26
*
@@ -43,12 +45,12 @@ import { noop } from '../util/noop';
43
45
* @see {@link windowWhen }
44
46
* @see {@link buffer }
45
47
*
46
- * @param { Observable<any> } windowBoundaries An Observable that completes the
48
+ * @param windowBoundaries An `ObservableInput` that completes the
47
49
* previous window and starts a new window.
48
50
* @return A function that returns an Observable of windows, which are
49
51
* Observables emitting values of the source Observable.
50
52
*/
51
- export function window < T > ( windowBoundaries : Observable < any > ) : OperatorFunction < T , Observable < T > > {
53
+ export function window < T > ( windowBoundaries : ObservableInput < any > ) : OperatorFunction < T , Observable < T > > {
52
54
return operate ( ( source , subscriber ) => {
53
55
let windowSubject : Subject < T > = new Subject < T > ( ) ;
54
56
@@ -73,7 +75,7 @@ export function window<T>(windowBoundaries: Observable<any>): OperatorFunction<T
73
75
) ;
74
76
75
77
// Subscribe to the window boundaries.
76
- windowBoundaries . subscribe (
78
+ innerFrom ( windowBoundaries ) . subscribe (
77
79
createOperatorSubscriber (
78
80
subscriber ,
79
81
( ) => {
0 commit comments