@talend/react-cmf-cqrs
Version:
@talend/react-cmf plugin for CQRS backend architecture
40 lines (38 loc) • 1.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ackProcessed = ackProcessed;
exports.default = ackReducer;
var _immutable = require("immutable");
var _index = require("../constants/index");
const DEFAULT_STATE = new _immutable.Map({});
/**
* ackReducer
* @param {Object} state redux
* @param {Object} action redux
* @return {Object} new state
*/
function ackReducer(state = DEFAULT_STATE, action) {
switch (action.type) {
case _index.ACK_ADD_CONTEXT:
return state.setIn([action.requestId, 'data'], action.data).setIn([action.requestId, 'actionCreator'], action.actionCreator);
case _index.ACK_RECEIVE_MESSAGE:
return state.setIn([action.requestId, 'received'], true);
case _index.ACK_DELETE:
return state.remove(action.requestId);
default:
return state;
}
}
function ackProcessed(state, action) {
if (action.ack) {
const newState = {
...state,
ack: ackReducer(state.ack, action.ack)
};
return newState;
}
return state;
}
//# sourceMappingURL=ack.js.map
;