orb-ui-firebase
Version:
Firebase with redux
62 lines (49 loc) • 2.15 kB
JavaScript
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import * as collectionsTypes from '../collections/types';
import * as docsTypes from '../docs/types';
import * as listsTypes from '../lists/types';
import * as pathsTypes from '../paths/types';
import * as types from './types';
function locations() {
var _extends2;
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var action = arguments[1];
var location = action.location,
locationValue = action.locationValue;
switch (action.type) {
case listsTypes.INIIALIZE:
case collectionsTypes.INIIALIZE:
case pathsTypes.VALUE_CHANGED:
case docsTypes.VALUE_CHANGED:
return _extends({}, state, (_extends2 = {}, _extends2[location] = locationValue, _extends2));
}
}
export default function initialization() {
var _extends3;
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments[1];
var path = action.path;
switch (action.type) {
case listsTypes.INIIALIZE:
case collectionsTypes.INIIALIZE:
case pathsTypes.VALUE_CHANGED:
case docsTypes.VALUE_CHANGED:
return _extends({}, state, (_extends3 = {}, _extends3[path] = locations(state[path], action), _extends3));
case types.CLEAR_INITIALIZATION:
return {};
case listsTypes.DESTROY:
case listsTypes.UNWATCH:
case collectionsTypes.DESTROY:
case collectionsTypes.UNWATCH:
case pathsTypes.DESTROY:
case pathsTypes.UNWATCH:
case docsTypes.DESTROY:
case docsTypes.UNWATCH:
var omit = state[path],
rest = _objectWithoutProperties(state, [path]);
return _extends({}, rest);
default:
return state;
}
}