Permalink
Browse files

feat(combineEpics): combineEpics() now transparently passes along _an…

…y_ arguments, not just action$, store.
  • Loading branch information...
jayphelps committed Sep 20, 2016
1 parent 8d74254 commit ee3efbfe2da921303f758a40570a2b794b8bbedf
Showing with 23 additions and 2 deletions.
  1. +4 −2 src/combineEpics.js
  2. +19 −0 test/combineEpics-spec.js
@@ -3,5 +3,7 @@ import { merge } from 'rxjs/observable/merge';
/**
Merges all epics into a single one.
*/
export const combineEpics = (...epics) => (actions, store) =>
merge(...(epics.map(epic => epic(actions, store))));
export const combineEpics = (...epics) => (...args) =>
merge(
...epics.map(epic => epic(...args))
);
@@ -1,5 +1,6 @@
/* globals describe it */
import { expect } from 'chai';
import sinon from 'sinon';
import { combineEpics, ActionsObservable } from '../';
import { Subject } from 'rxjs/Subject';
import { map } from 'rxjs/operator/map';
@@ -32,4 +33,22 @@ describe('combineEpics', () => {
{ type: 'DELEGATED2', action: { type: 'ACTION2' }, store },
]);
});

it('should pass along every argument arbitrarily', () => {
const epic1 = sinon.stub();
const epic2 = sinon.stub();

const rootEpic = combineEpics(
epic1,
epic2
);

rootEpic(1, 2, 3, 4);

expect(epic1.callCount).to.equal(1);
expect(epic2.callCount).to.equal(1);

expect(epic1.firstCall.args).to.deep.equal([1, 2, 3, 4]);
expect(epic2.firstCall.args).to.deep.equal([1, 2, 3, 4]);
});
});

0 comments on commit ee3efbf

Please sign in to comment.