Skip to content

Commit a81d842

Browse files
committed
feat: Record the source of the state change
1 parent 7fdc90d commit a81d842

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/rxloop.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function rxloop( config = {} ) {
3131
stream[`reducer_${type}$`].pipe(
3232
map(action => {
3333
const rtn = this.createReducer(action, reducers[type]);
34+
action.__source__ = { reducer: type };
3435
rtn.__action__ = action;
3536
return rtn;
3637
}),
@@ -94,6 +95,7 @@ export function rxloop( config = {} ) {
9495
});
9596
const rtn = this.createReducer(action, reducers[reducer]);
9697
action.type = `${name}/${action.type}`;
98+
action.__source__ = { epic: type };
9799
rtn.__action__ = action;
98100
return rtn;
99101
}),

test/plugins.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,21 +313,21 @@ describe('Basic api', () => {
313313
expect(mockfn.mock.calls.length).toBe(3);
314314
expect(mockfn.mock.calls[0][0]).toEqual({
315315
state: { counter: 1 },
316-
reducerAction: { type: 'counter/inc' },
316+
reducerAction: { type: 'counter/inc', __source__: { reducer: 'inc' } },
317317
model: 'counter',
318318
type: 'plugin',
319319
action: 'onStatePatch',
320320
});
321321
expect(mockfn.mock.calls[1][0]).toEqual({
322322
state: { counter: 2 },
323-
reducerAction: { type: 'counter/inc' },
323+
reducerAction: { type: 'counter/inc', __source__: { reducer: 'inc' } },
324324
model: 'counter',
325325
type: 'plugin',
326326
action: 'onStatePatch',
327327
});
328328
expect(mockfn.mock.calls[2][0]).toEqual({
329329
state: { counter: 1 },
330-
reducerAction: { type: 'counter/dec' },
330+
reducerAction: { type: 'counter/dec', __source__: { reducer: 'dec' } },
331331
model: 'counter',
332332
type: 'plugin',
333333
action: 'onStatePatch',

0 commit comments

Comments
 (0)