diff --git a/package.json b/package.json index 607ed7d..cec65db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redux-and-the-rest", - "version": "5.0.0", + "version": "5.1.0", "description": "Declarative, flexible Redux integration with your RESTful API", "main": "index.js", "scripts": { diff --git a/src/actions/RESTful/fetchItem.js b/src/actions/RESTful/fetchItem.js index 0412304..77a713b 100644 --- a/src/actions/RESTful/fetchItem.js +++ b/src/actions/RESTful/fetchItem.js @@ -77,8 +77,8 @@ function actionCreator(options, paramsOrActionCreatorOptions, optionalActionCrea }; } -function localActionCreator(options, paramsOrActionCreatorOptions, optionalActionCreatorOptions) { - throw 'fetchItem is not supported with the localOnly option. User getOrFetchItem instead.'; +function localActionCreator() { + throw new Error('fetchItem is not supported with the localOnly option. User getOrFetchItem instead.'); } /** ************************************************************************************************************ diff --git a/src/actions/RESTful/fetchList.js b/src/actions/RESTful/fetchList.js index ef49039..926eda3 100644 --- a/src/actions/RESTful/fetchList.js +++ b/src/actions/RESTful/fetchList.js @@ -84,8 +84,8 @@ function actionCreator(options, params, actionCreatorOptions = {}) { }; } -function localActionCreator(options, paramsOrActionCreatorOptions, optionalActionCreatorOptions) { - throw 'fetchList is not supported with the localOnly option. User getOrFetchList instead.'; +function localActionCreator() { + throw new Error('fetchList is not supported with the localOnly option. User getOrFetchList instead.'); } /** ************************************************************************************************************ diff --git a/src/resources.js b/src/resources.js index 472b028..33fe199 100644 --- a/src/resources.js +++ b/src/resources.js @@ -279,21 +279,17 @@ function resources(resourceOptions, actionOptions = {}) { } if (hasKey(actions, 'newItem')) { - resourceDefinition.getOrInitializeNewItem = (resourcesState, paramsOrValues, valuesOrActionCreatorOptions, optionalActionCreatorOptions) => { - return getOrInitializeNewItem({ action: actions.newItem, newItem: resourceDefinition.newItem }, resourcesState, paramsOrValues, valuesOrActionCreatorOptions, optionalActionCreatorOptions); - }; + resourceDefinition.getOrInitializeNewItem = (resourcesState, paramsOrValues, valuesOrActionCreatorOptions, optionalActionCreatorOptions) => getOrInitializeNewItem({ action: actions.newItem, newItem: resourceDefinition.newItem }, resourcesState, paramsOrValues, valuesOrActionCreatorOptions, optionalActionCreatorOptions); } if (hasKey(actions, 'createItem') && hasKey(actions, 'updateItem')) { - resourceDefinition.saveItem = (resourcesState, paramsOrValues, valuesOrActionCreatorOptions, optionalActionCreatorOptions) => { - return saveItem({ + resourceDefinition.saveItem = (resourcesState, paramsOrValues, valuesOrActionCreatorOptions, optionalActionCreatorOptions) => saveItem({ createItem: resourceDefinition.createItem, updateItem: resourceDefinition.updateItem, // Resource options required by handler keyBy, singular }, resourcesState, paramsOrValues, valuesOrActionCreatorOptions, optionalActionCreatorOptions); - }; } if (hasKey(actions, 'fetchList')) {