UNPKG

awv3

Version:
35 lines (29 loc) 971 B
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import without from 'lodash/without'; import { types as pluginTypes } from './plugins'; import { types as ConnectionTypes } from './connections'; var reducer = function reducer(state, _ref) { if (state === void 0) { state = { plugins: [], connections: [] }; } var type = _ref.type, payload = _objectWithoutProperties(_ref, ["type"]); switch (type) { case ConnectionTypes.register: return _extends({}, state, { connections: state.connections.concat([payload.id]) }); case ConnectionTypes.unregister: var objects = Array.isArray(payload.ids) ? payload.ids : [payload.ids]; return _extends({}, state, { connections: without.apply(void 0, [state.connections].concat(objects)) }); default: return state; } }; export { reducer };