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 {
1010 ActionsSubject ,
1111} from '@ngrx/store' ;
1212import { 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' ;
1416
1517describe ( 'Actions' , function ( ) {
1618 let actions$ : Actions ;
@@ -75,4 +77,17 @@ describe('Actions', function() {
7577 actions . forEach ( action => dispatcher . next ( { type : action } ) ) ;
7678 dispatcher . complete ( ) ;
7779 } ) ;
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+ } ) ;
7893} ) ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export class Actions<V = Action> extends Observable<V> {
2323 }
2424
2525 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 > ) ;
2727 }
2828}
2929
You can’t perform that action at this time.
0 commit comments