UNPKG

oneframe-react

Version:

Oneframe React ## Components, Hooks, Helper Functions & State Management

32 lines (31 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const lodash_1 = require("lodash"); const immutable_1 = require("immutable"); exports.config = { actionsCreators: { setData: (_a, actions, nextState) => { const currentStore = nextState; const currentPayload = lodash_1.omit(currentStore, ['onSuccess', 'onError', 'currentName']); const currentStatus = currentStore.statusCode || 1; const currentName = currentStore.currentName || ''; const store = Object.assign(Object.assign({}, _a), { [currentName]: currentPayload }); if (nextState && nextState.hasOwnProperty('currentName')) { const status = Number(currentStatus) >= 200 && Number(currentStatus) < 400; if (status) { currentStore.onSuccess && currentStore.onSuccess(store, currentPayload, currentStatus); } else { currentStore.onError && currentStore.onError(store, currentPayload, currentStatus); } } return immutable_1.fromJS(store).toJS(store); }, loading: (_a, _b, nextState) => { return nextState; }, reset: (_a, _b, nextState) => { return nextState; }, }, };