@@ -13,7 +13,7 @@ import 'rxjs/add/operator/map';
13
13
import 'rxjs/add/operator/mergeMap' ;
14
14
import 'rxjs/add/operator/scan' ;
15
15
import { BehaviorSubject } from 'rxjs/BehaviorSubject' ;
16
- import { Observable , SubscribableOrPromise } from 'rxjs/Observable' ;
16
+ import { Observable , Subscribable , SubscribableOrPromise } from 'rxjs/Observable' ;
17
17
import { Subject } from 'rxjs/Subject' ;
18
18
19
19
import Action from './action' ;
@@ -94,7 +94,7 @@ export default class DataStore<TState, TAction extends Action = Action, TTransfo
94
94
subscriber : Subscriber < TTransformedState > ,
95
95
...filters : Array < Filter < TTransformedState > >
96
96
) : Unsubscriber {
97
- let state$ : Observable < any > = this . _state$ ;
97
+ let state$ : Observable < TTransformedState > = this . _state$ ;
98
98
99
99
if ( filters . length > 0 ) {
100
100
state$ = state$ . distinctUntilChanged ( ( stateA , stateB ) =>
@@ -145,13 +145,14 @@ export default class DataStore<TState, TAction extends Action = Action, TTransfo
145
145
return new Promise ( ( resolve , reject ) => {
146
146
const error$ = this . _getDispatchError ( options . queueId ) ;
147
147
const transformedAction$ = this . _options . actionTransformer (
148
- Observable . from ( action$ ) . map ( ( action ) =>
149
- options . queueId ? merge ( { } , action , { meta : { queueId : options . queueId } } ) : action
150
- )
148
+ Observable . from ( action$ )
149
+ . map ( ( action ) =>
150
+ options . queueId ? merge ( { } , action , { meta : { queueId : options . queueId } } ) : action
151
+ ) as Subscribable < TDispatchAction >
151
152
) ;
152
153
153
154
this . _getDispatcher ( options . queueId ) . next (
154
- transformedAction$
155
+ Observable . from ( transformedAction$ )
155
156
. map ( ( action , index ) => {
156
157
if ( index === 0 ) {
157
158
error$ . first ( ) . subscribe ( reject ) ;
@@ -205,7 +206,7 @@ export default class DataStore<TState, TAction extends Action = Action, TTransfo
205
206
206
207
export interface DataStoreOptions < TState , TAction , TTransformedState > {
207
208
shouldWarnMutation : boolean ;
208
- actionTransformer : ( action : Observable < TAction > ) => Observable < TAction > ;
209
+ actionTransformer : ( action : Subscribable < TAction > ) => Subscribable < TAction > ;
209
210
stateTransformer : ( state : TState ) => TTransformedState ;
210
211
}
211
212
@@ -214,4 +215,4 @@ interface StateTuple<TState, TTransformedState> {
214
215
transformedState : TTransformedState ;
215
216
}
216
217
217
- type Dispatcher < TAction > = Subject < Observable < TAction > > ;
218
+ type Dispatcher < TAction > = Subject < Subscribable < TAction > > ;
0 commit comments