lore-hook-connect
Version:
A lore hook that generates dialogs using Bootstrap
40 lines (32 loc) • 950 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
function InvalidGetStateCall(reducerKey) {
var error = new Error('\n Invalid call to \'getState(\'' + reducerKey + '\')\'. Missing required attribute \'id\'.\n Expected method call to look like this:\n \n getState(\'' + reducerKey + '\', {\n id: 1\n })');
error.name = 'InvalidGetStateCall';
return error;
}
/**
* byId Connection Blueprint
*/
exports.default = {
defaults: {
id: null
},
verifyParams: function verifyParams(params) {
if (!params.id) {
throw new InvalidGetStateCall(this.reducerKey);
}
},
getPayload: function getPayload(reducerState, params) {
var key = params.id;
return reducerState[key];
},
callAction: function callAction(action, params) {
var id = params.id;
var query = params.query;
return action(id, query).payload;
}
};
module.exports = exports['default'];
;