From 33d48e7b0204386aed5d90da98bdc861eb117965 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 25 Jan 2018 06:12:14 -0800 Subject: [PATCH] fix(Effects): Provide instance from actions to ofType lettable operator (#751) Closes #739 --- modules/effects/spec/actions.spec.ts | 17 ++++++++++++++++- modules/effects/src/actions.ts | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) 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); } }