Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 ee3efbf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/combineEpics.js
Expand Up @@ -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))
);
19 changes: 19 additions & 0 deletions test/combineEpics-spec.js
@@ -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';
Expand Down Expand Up @@ -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.