diff --git a/modules/effects/spec/actions.spec.ts b/modules/effects/spec/actions.spec.ts index 1009a138f8..c431bdc0c1 100644 --- a/modules/effects/spec/actions.spec.ts +++ b/modules/effects/spec/actions.spec.ts @@ -10,7 +10,9 @@ import { ActionsSubject, } from '@ngrx/store'; import { Actions, ofType } from '../'; -import { map, toArray } from 'rxjs/operators'; +import { map, toArray, switchMap } from 'rxjs/operators'; +import { hot, cold } from 'jasmine-marbles'; +import { of } from 'rxjs/observable/of'; describe('Actions', function() { let actions$: Actions; @@ -75,4 +77,17 @@ describe('Actions', function() { actions.forEach(action => dispatcher.next({ type: action })); dispatcher.complete(); }); + + it('should support using the ofType instance operator', () => { + const action = { type: ADD }; + + const response = cold('-b', { b: true }); + const expected = cold('--c', { c: true }); + + const effect$ = new Actions(hot('-a', { a: action })) + .ofType(ADD) + .pipe(switchMap(() => response)); + + expect(effect$).toBeObservable(expected); + }); }); diff --git a/modules/effects/src/actions.ts b/modules/effects/src/actions.ts index 8c7d1c46e6..a7e6aaa448 100644 --- a/modules/effects/src/actions.ts +++ b/modules/effects/src/actions.ts @@ -23,7 +23,7 @@ export class Actions extends Observable { } ofType(...allowedTypes: string[]): Actions { - return ofType(...allowedTypes)(this.source as Actions); + return ofType(...allowedTypes)(this as Actions); } }