From 344d28d1abd07aedb70c145c57f12b31953b8e6a Mon Sep 17 00:00:00 2001 From: Aleck Greenham Date: Fri, 9 Oct 2020 07:38:33 +0100 Subject: [PATCH] v5.1.0 --- package.json | 2 +- src/actions/RESTful/fetchItem.js | 4 ++-- src/actions/RESTful/fetchList.js | 4 ++-- src/resources.js | 8 ++------ 4 files changed, 7 insertions(+), 11 deletions(-) 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')) {