Skip to content

Commit

Permalink
fix(Effects): Provide instance from actions to ofType lettable operat…
Browse files Browse the repository at this point in the history
…or (#751)

Closes #739
  • Loading branch information
brandonroberts authored and MikeRyanDev committed Jan 25, 2018
1 parent 25d9a08 commit 33d48e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion modules/effects/spec/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion modules/effects/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Actions<V = Action> extends Observable<V> {
}

ofType<V2 extends V = V>(...allowedTypes: string[]): Actions<V2> {
return ofType<any>(...allowedTypes)(this.source as Actions<V2>);
return ofType<any>(...allowedTypes)(this as Actions<any>);
}
}

Expand Down

0 comments on commit 33d48e7

Please sign in to comment.