1
1
import { Operator } from '../Operator' ;
2
- import { Observable , ObservableOrPromise } from '../Observable' ;
2
+ import { Observable , SubscribableOrPromise } from '../Observable' ;
3
3
import { Subscriber } from '../Subscriber' ;
4
4
import { Subscription } from '../Subscription' ;
5
5
@@ -13,16 +13,16 @@ import {subscribeToResult} from '../util/subscribeToResult';
13
13
* @method throttle
14
14
* @owner Observable
15
15
*/
16
- export function throttle < T > ( durationSelector : ( value : T ) => ObservableOrPromise < number > ) : Observable < T > {
16
+ export function throttle < T > ( durationSelector : ( value : T ) => SubscribableOrPromise < number > ) : Observable < T > {
17
17
return this . lift ( new ThrottleOperator ( durationSelector ) ) ;
18
18
}
19
19
20
20
export interface ThrottleSignature < T > {
21
- ( durationSelector : ( value : T ) => ObservableOrPromise < number > ) : Observable < T > ;
21
+ ( durationSelector : ( value : T ) => SubscribableOrPromise < number > ) : Observable < T > ;
22
22
}
23
23
24
24
class ThrottleOperator < T > implements Operator < T , T > {
25
- constructor ( private durationSelector : ( value : T ) => ObservableOrPromise < number > ) {
25
+ constructor ( private durationSelector : ( value : T ) => SubscribableOrPromise < number > ) {
26
26
}
27
27
28
28
call ( subscriber : Subscriber < T > ) : Subscriber < T > {
@@ -34,7 +34,7 @@ class ThrottleSubscriber<T, R> extends OuterSubscriber<T, R> {
34
34
private throttled : Subscription ;
35
35
36
36
constructor ( protected destination : Subscriber < T > ,
37
- private durationSelector : ( value : T ) => ObservableOrPromise < number > ) {
37
+ private durationSelector : ( value : T ) => SubscribableOrPromise < number > ) {
38
38
super ( destination ) ;
39
39
}
40
40
@@ -45,7 +45,7 @@ class ThrottleSubscriber<T, R> extends OuterSubscriber<T, R> {
45
45
}
46
46
47
47
private tryDurationSelector ( value : T ) : void {
48
- let duration : ObservableOrPromise < number > = null ;
48
+ let duration : SubscribableOrPromise < number > = null ;
49
49
try {
50
50
duration = this . durationSelector ( value ) ;
51
51
} catch ( err ) {
@@ -55,7 +55,7 @@ class ThrottleSubscriber<T, R> extends OuterSubscriber<T, R> {
55
55
this . emitAndThrottle ( value , duration ) ;
56
56
}
57
57
58
- private emitAndThrottle ( value : T , duration : ObservableOrPromise < number > ) {
58
+ private emitAndThrottle ( value : T , duration : SubscribableOrPromise < number > ) {
59
59
this . add ( this . throttled = subscribeToResult ( this , duration ) ) ;
60
60
this . destination . next ( value ) ;
61
61
}
0 commit comments