File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ import {
10
10
ActionsSubject ,
11
11
} from '@ngrx/store' ;
12
12
import { Actions , ofType } from '../' ;
13
- import { map , toArray } from 'rxjs/operators' ;
13
+ import { map , toArray , switchMap } from 'rxjs/operators' ;
14
+ import { hot , cold } from 'jasmine-marbles' ;
15
+ import { of } from 'rxjs/observable/of' ;
14
16
15
17
describe ( 'Actions' , function ( ) {
16
18
let actions$ : Actions ;
@@ -75,4 +77,17 @@ describe('Actions', function() {
75
77
actions . forEach ( action => dispatcher . next ( { type : action } ) ) ;
76
78
dispatcher . complete ( ) ;
77
79
} ) ;
80
+
81
+ it ( 'should support using the ofType instance operator' , ( ) => {
82
+ const action = { type : ADD } ;
83
+
84
+ const response = cold ( '-b' , { b : true } ) ;
85
+ const expected = cold ( '--c' , { c : true } ) ;
86
+
87
+ const effect$ = new Actions ( hot ( '-a' , { a : action } ) )
88
+ . ofType ( ADD )
89
+ . pipe ( switchMap ( ( ) => response ) ) ;
90
+
91
+ expect ( effect$ ) . toBeObservable ( expected ) ;
92
+ } ) ;
78
93
} ) ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export class Actions<V = Action> extends Observable<V> {
23
23
}
24
24
25
25
ofType < V2 extends V = V > ( ...allowedTypes : string [ ] ) : Actions < V2 > {
26
- return ofType < any > ( ...allowedTypes ) ( this . source as Actions < V2 > ) ;
26
+ return ofType < any > ( ...allowedTypes ) ( this as Actions < any > ) ;
27
27
}
28
28
}
29
29
You can’t perform that action at this time.
0 commit comments