Skip to content

Commit

Permalink
feat(effects): add support for effects of different instances of same…
Browse files Browse the repository at this point in the history
… class (#1249)

Closes #1246
  • Loading branch information
dummdidumm authored and brandonroberts committed Aug 22, 2018
1 parent 1aa4b63 commit 518e561
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 12 additions & 1 deletion modules/effects/spec/effect_sources.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,23 @@ describe('EffectSources', () => {
});

it('should ignore duplicate sources', () => {
const sources$ = cold('--a--a--a--', {
a: new SourceA(),
});
const expected = cold('--a--------', { a });

const output = toActions(sources$);

expect(output).toBeObservable(expected);
});

it('should resolve effects from same class but different instances', () => {
const sources$ = cold('--a--b--c--', {
a: new SourceA(),
b: new SourceA(),
c: new SourceA(),
});
const expected = cold('--a--------', { a });
const expected = cold('--a--a--a--', { a });

const output = toActions(sources$);

Expand Down
3 changes: 1 addition & 2 deletions modules/effects/src/effect_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from 'rxjs/operators';

import { verifyOutput } from './effect_notification';
import { getSourceForInstance } from './effects_metadata';
import { resolveEffectSource } from './effects_resolver';

@Injectable()
Expand All @@ -29,7 +28,7 @@ export class EffectSources extends Subject<any> {
*/
toActions(): Observable<Action> {
return this.pipe(
groupBy(getSourceForInstance),
groupBy(source => source),
mergeMap(source$ =>
source$.pipe(
exhaustMap(resolveEffectSource),
Expand Down

0 comments on commit 518e561

Please sign in to comment.