Skip to content

Commit 254903e

Browse files
Frozzy6olegman
authored andcommitted
Upgraded paramsCreattor to payload transformer (#26)
1 parent 4febe6f commit 254903e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/createAction.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ export function clearRegistry() : any {
1111
actionsRegistry.clear();
1212
}
1313

14-
export default function createAction(type: string, paramsCreator: paramsCreator = () => ({})): any {
14+
const defaultTransform = (...args) => ({ ...args });
15+
16+
export default function createAction(type: string, transform = defaultTransform): any {
1517
if (actionsRegistry.has(type)) {
1618
throw `Duplicate action ${type}`;
1719
} else {
1820
actionsRegistry.add(type);
1921
}
2022

2123
const actionCreator = (...args) => {
22-
const params = paramsCreator(...args);
24+
const params = transform(...args);
2325
if ('type' in params) {
2426
console.warn('Property type is reserved by action');
2527
}

0 commit comments

Comments
 (0)