@galette/core
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -8,2 +8,2 @@ import { Action, ActionLifecycleOptions } from "../store/redux/reducers"; | ||
export declare function reduceItems(state: object, action: Action, options: HydraOptions): {}; | ||
export declare function reduceListAndItems(state: object, action: Action, options: HydraOptions): import("src/store/redux/reducers").ReducedList; | ||
export declare function reduceListAndItems(state: object, action: Action, options: HydraOptions): {}; |
@@ -33,4 +33,4 @@ export declare type Action = { | ||
}; | ||
export declare const reduceListAndItems: (state: {}, action: Action, options: ReduceListOptions) => ReducedList; | ||
export declare const reduceListAndItems: (state: {}, action: Action, options: ReduceListOptions) => {}; | ||
export declare const reduceItems: (state: {}, action: Action, options: ReduceItemsOptions) => {}; | ||
export declare const reduceList: (state: any, action: Action, options: ReduceListOptions) => ReducedList; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var functions_1 = require("./functions"); | ||
var resolveActionsToHandle = function (options) { | ||
if (options.actionPrefix) { | ||
options.actions = { | ||
starting: options.actionPrefix + '_SENT', | ||
failed: options.actionPrefix + '_FAILED', | ||
succeed: options.actionPrefix + '_RECEIVED', | ||
}; | ||
} | ||
return options.actions; | ||
}; | ||
exports.reduceListAndItems = function (state, action, options) { | ||
if (state === void 0) { state = {}; } | ||
var actions = resolveActionsToHandle(options); | ||
var actionTypes = Object.keys(actions).map(function (key) { return actions[key]; }); | ||
if (actionTypes.indexOf(action.type) === -1) { | ||
return state; | ||
} | ||
return exports.reduceList(exports.reduceItems(state, action, options), action, options); | ||
@@ -32,9 +47,3 @@ }; | ||
if (state === void 0) { state = {}; } | ||
if (options.actionPrefix) { | ||
options.actions = { | ||
starting: options.actionPrefix + '_SENT', | ||
failed: options.actionPrefix + '_FAILED', | ||
succeed: options.actionPrefix + '_RECEIVED', | ||
}; | ||
} | ||
var actions = resolveActionsToHandle(options); | ||
// If the list does not exists. | ||
@@ -44,3 +53,3 @@ if (!state[options.listKeyInState]) { | ||
} | ||
if (action.type === options.actions.starting) { | ||
if (action.type === actions.starting) { | ||
return functions_1.updateItem(state, options.listKeyInState, { | ||
@@ -51,3 +60,3 @@ loading: true, | ||
} | ||
if (action.type === options.actions.succeed) { | ||
if (action.type === actions.succeed) { | ||
var items = itemsFromAction(action, options); | ||
@@ -70,3 +79,3 @@ var totalItems = 'function' === typeof options.totalItems | ||
} | ||
if (action.type === options.actions.failed) { | ||
if (action.type === actions.failed) { | ||
var errorResolver = options.errorMessageResolver ? options.errorMessageResolver : defaultErrorMessageResolver; | ||
@@ -73,0 +82,0 @@ return functions_1.updateItem(state, options.listKeyInState, { |
{ | ||
"name": "@galette/core", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "npm run build-ts", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32137
524