UNPKG

lore

Version:

Convention-driven framework for building React-Redux applications

21 lines (19 loc) 780 B
import _mapValues from 'lodash/mapValues'; import _assign from 'lodash/assign'; /* eslint no-param-reassign: "warn" */ import { Hook } from 'lore-utils'; import userHooksLoader from '../loaders/userHooks'; /** * Obtain and merge the core hooks and user hooks. If a user hook exists with * the same name as a core hook the user hook takes priority. * * @returns {Object} Final set of hooks that should be loaded into the application */ export default function getHooks(hookOverrides) { var userHookDefinitions = userHooksLoader.load(); var hookDefinitions = _assign({}, userHookDefinitions, hookOverrides); var hooks = _mapValues(hookDefinitions, function (definition, hookName) { definition.id = hookName; return new Hook(definition); }); return hooks; }