Skip to content

Commit 33d48e7

Browse files
brandonrobertsMikeRyanDev
authored andcommitted
fix(Effects): Provide instance from actions to ofType lettable operator (#751)
Closes #739
1 parent 25d9a08 commit 33d48e7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

modules/effects/spec/actions.spec.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import {
1010
ActionsSubject,
1111
} from '@ngrx/store';
1212
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';
1416

1517
describe('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
});

modules/effects/src/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)