How to use the dot-prop-immutable.delete function in dot-prop-immutable

To help you get started, we’ve selected a few dot-prop-immutable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / webiny-app-page-builder / src / editor / actions / actions.js View on Github external
next(action);

    store.dispatch(deactivateElement());
    const state = store.getState();

    let { element } = action.payload;
    let parent = getParentElementWithChildren(state, element.id);

    // Remove child from parent
    // $FlowFixMe
    if (!parent) {
        return;
    }

    const index = parent.elements.findIndex(el => el.id === element.id);
    parent = dotProp.delete(parent, "elements." + index);
    store.dispatch(updateElement({ element: parent }));

    // Execute `onChildDeleted` if defined
    const plugin = getPlugin(parent.type);
    if (!plugin) {
        return;
    }

    if (typeof plugin.onChildDeleted === "function") {
        plugin.onChildDeleted({ element: parent, child: element });
    }
});
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
next(action);

    store.dispatch(deactivateElement());
    const state = store.getState();

    let { element } = action.payload;
    let parent = getParentElementWithChildren(state, element.id);

    // Remove child from parent
    // $FlowFixMe
    if (!parent) {
        return;
    }

    const index = parent.elements.findIndex(el => el.id === element.id);
    parent = dotProp.delete(parent, "elements." + index);
    store.dispatch(updateElement({ element: parent }));

    // Execute `onChildDeleted` if defined
    const plugin = getPlugin(parent.type);
    if (!plugin) {
        return;
    }

    if (typeof plugin.onChildDeleted === "function") {
        plugin.onChildDeleted({ element: parent, child: element });
    }
});
github greymass / eos-voter / app / shared / containers / Global / Blockchain / Form.js View on Github external
static getDerivedStateFromProps(props, state) {
    const { validate } = props;
    let derived = {};
    if (state.values.node) {
      if (validate.NODE === 'PENDING') {
        derived = set(state, 'valids.endpoint', false);
        derived = set(derived, 'loading.endpoint', true);
        derived = del(derived, 'errors.endpoint');
      }
      if (validate.NODE === 'FAILURE') {
        derived = set(state, 'errors.endpoint', validate.NODE_ERROR);
        derived = del(derived, 'loading.endpoint');
      }
      if (validate.NODE === 'SUCCESS') {
        derived = set(state, 'valids.endpoint', true);
        derived = del(derived, 'loading.endpoint');
        derived = del(derived, 'errors.endpoint');
      }
    }
    return derived;
  }
  componentDidMount() {
github webiny / webiny-js / packages / webiny-app-page-builder / src / editor / actions / actions.js View on Github external
addReducer([DEACTIVATE_PLUGIN], "ui.plugins", (state, action) => {
    const { name } = action.payload;
    const plugin = getPlugin(name);
    if (!plugin) {
        return state;
    }

    let typePlugins = dotProp.get(state, plugin.type);
    if (!Array.isArray(typePlugins)) {
        typePlugins = [];
    }

    const alreadyActive = typePlugins.findIndex(pl => pl.name === plugin.name);

    if (alreadyActive > -1) {
        typePlugins = dotProp.delete(typePlugins, alreadyActive);
    }

    return dotProp.set(state, `${plugin.type}`, typePlugins);
});
github greymass / eos-voter / app / shared / components / Tools / Form / Permissions / Auth.js View on Github external
onRemoveKey = (e, { name }) => {
    const { [`${name}.key`]: value, ...validFields } = this.state.validFields;
    this.setState({
      auth: del(this.state.auth, name),
      validFields
    });
  }
  onSubmit = () => {
github webiny / webiny-js / packages / webiny-ui / src / DynamicFieldset / Fieldset.js View on Github external
removeData = (index: number) => {
        const { value, onChange } = this.props;
        onChange(dotProp.delete(value, index));
    };
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
const plugin = getPlugin(name);

    if (!plugin) {
        return state;
    }

    let typePlugins = dotProp.get(state, plugin.type);
    if (!Array.isArray(typePlugins)) {
        typePlugins = [];
    }

    const alreadyActive = typePlugins.findIndex(pl => pl.name === plugin.name);

    if (alreadyActive > -1) {
        typePlugins = dotProp.delete(typePlugins, alreadyActive);
    } else {
        if (closeOtherInGroup) {
            typePlugins = [{ name, params }];
        } else {
            typePlugins.push({ name, params });
        }
    }

    return dotProp.set(state, `${plugin.type}`, typePlugins);
});
github spaceuptech / automate-redux / index.js View on Github external
case "PUSH":
        return dotProp.merge(state, action.path, [action.value]);

      case "INCREMENT":
        var initialValue = Number(dotProp.get(state, action.path, 0))
        var newValue = initialValue + action.value
        return dotProp.set(state, action.path, newValue)

      case "DECREMENT":
          var initialValue = Number(dotProp.get(state, action.path, 0))
          var newValue = initialValue - action.value
          return dotProp.set(state, action.path, newValue)

      case "DELETE":
        return dotProp.delete(state, action.path);

      default:
        return state;
    }
  };
};
github Lemonpeach / hydrogen / packages / redux-hydrogen / src / reducers / modifiers.js View on Github external
export const remove = id => (state = initialState) => dotprop.delete(
  state,
  `data.${id}`
);
github ealgis / ealgis / frontend / src / reducers / index.tsx View on Github external
case RECEIVE_MAPS:
            return action.maps
        case RECEIVE_UPDATED_MAP:
            return dotProp.set(state, `${action.map.id}`, action.map)
        case CREATE_MAP:
            return {
                ...state,
                [action.map.id]: action.map
            }
        case DELETE_MAP:
            let { [action.mapId]: deletedItem, ...rest } = state
            return rest
        case RECEIVE_UPDATED_LAYER:
            return dotProp.set(state, `${action.mapId}.json.layers.${action.layerId}`, action.layer)
        case RECEIVE_DELETE_MAP_LAYER:
            return dotProp.delete(state, `${action.mapId}.json.layers.${action.layerId}`)
        case RECEIVE_CLONE_MAP_LAYER:
            let layerCopy = JSON.parse(JSON.stringify(state[action.mapId].json.layers[action.layerId]))
            layerCopy.name += " Copy"
            return dotProp.set(state, `${action.mapId}.json.layers`, [...state[action.mapId].json.layers, layerCopy])
        case CHANGE_LAYER_VISIBILITY:
            return dotProp.toggle(state, `${action.mapId}.json.layers.${action.layerId}.visible`)
        case CHANGE_LAYER_PROPERTY:
            return dotProp.set(state, `${action.mapId}.json.layers.${action.layerId}.${action.layerPropertyPath}`, action.layerPropertyValue)
        case MERGE_LAYER_PROPERTIES:
            const newLayer = merge(dotProp.get(state, `${action.mapId}.json.layers.${action.layerId}`), action.layer)
            return dotProp.set(state, `${action.mapId}.json.layers.${action.layerId}`, newLayer)
        case RECEIVE_SET_MAP_ORIGIN:
            return dotProp.set(state, `${action.mapId}.json.map_defaults`, {
                lat: action.position.center.lat,
                lon: action.position.center.lon,
                zoom: action.position.zoom,

dot-prop-immutable

Immutable version of dot-prop with some extensions

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis