Skip to content

Commit

Permalink
Release 2.0.0-0
Browse files Browse the repository at this point in the history
  • Loading branch information
svagi committed Jul 3, 2017
1 parent 86f6023 commit a081e7b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
16 changes: 9 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function createRoutine(prefix) {
args[_key2 - 1] = arguments[_key2];
}

return createAction.apply(undefined, [routine.TRIGGER, enhancer(payload)].concat(_toConsumableArray(args)));
return enhancer(createAction.apply(undefined, [routine.TRIGGER, payload].concat(_toConsumableArray(args))));
},
request: function request(payload) {
routine.state.request = true;
Expand All @@ -70,7 +70,7 @@ function createRoutine(prefix) {
args[_key3 - 1] = arguments[_key3];
}

return createAction.apply(undefined, [routine.REQUEST, enhancer(payload)].concat(_toConsumableArray(args)));
return enhancer(createAction.apply(undefined, [routine.REQUEST, payload].concat(_toConsumableArray(args))));
},
success: function success(payload) {
routine.state.success = true;
Expand All @@ -80,7 +80,7 @@ function createRoutine(prefix) {
args[_key4 - 1] = arguments[_key4];
}

return createAction.apply(undefined, [routine.SUCCESS, enhancer(payload)].concat(_toConsumableArray(args)));
return enhancer(createAction.apply(undefined, [routine.SUCCESS, payload].concat(_toConsumableArray(args))));
},
failure: function failure(payload) {
routine.state.success = false;
Expand All @@ -90,7 +90,7 @@ function createRoutine(prefix) {
args[_key5 - 1] = arguments[_key5];
}

return createAction.apply(undefined, [routine.FAILURE, enhancer(payload)].concat(_toConsumableArray(args)));
return enhancer(createAction.apply(undefined, [routine.FAILURE, payload].concat(_toConsumableArray(args))));
},
fulfill: function fulfill(payload) {
routine.state.fulfill = true;
Expand All @@ -99,13 +99,15 @@ function createRoutine(prefix) {
args[_key6 - 1] = arguments[_key6];
}

return createAction.apply(undefined, [routine.FULFILL, enhancer(payload)].concat(_toConsumableArray(args)));
return enhancer(createAction.apply(undefined, [routine.FULFILL, payload].concat(_toConsumableArray(args))));
}
};
function call(payload) {
var enhancer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
for (var _len7 = arguments.length, args = Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
args[_key7 - 1] = arguments[_key7];
}

return enhancer(routine.trigger(payload));
return routine.trigger.apply(routine, [payload].concat(args));
}
return Object.assign(call, routine);
}
16 changes: 3 additions & 13 deletions lib/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ describe('createRoutine', function () {
expect(state.fulfill).toBe(true);
});
it('should modify payload with enhancer', function () {
var routine = (0, _index.createRoutine)('test', function (payload) {
return payload + 1;
var routine = (0, _index.createRoutine)('test', function (action) {
action.payload += 1;
return action;
});
expect(routine.trigger(0).payload).toBe(1);
expect(routine.request(0).payload).toBe(1);
Expand All @@ -91,17 +92,6 @@ describe('createRoutine', function () {
expect(action.type).toContain('TRIGGER');
expect(routine.state.trigger).toBe(true);
});
it('should trigger on routine invocation with enhancer', function () {
var routine = (0, _index.createRoutine)('test');
var enhancer = function enhancer(action) {
action.payload = action.payload + 1;
return action;
};
var action = routine(1, enhancer);
expect(action.type).toContain('TRIGGER');
expect(action.payload).toBe(2);
expect(routine.state.trigger).toBe(true);
});
});

describe('createAction', function () {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-routines",
"version": "1.0.0",
"version": "2.0.0-0",
"description": "Simple, yet effective tool for removing Redux boilerplate code.",
"keywords": [
"redux",
Expand Down

0 comments on commit a081e7b

Please sign in to comment.