How to use the object-path-immutable.set function in object-path-immutable

To help you get started, we’ve selected a few object-path-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 arthurgallo / reducerless-redux / __tests__ / reducerless.js View on Github external
        update: state => im.set(state, 'hello', 'kitty'),
      });
github cantierecreativo / redux-bees / src / reducers / requests.js View on Github external
let newState = state;

    if (action.payload.body) {
      const { data, meta } = action.payload.body;

      let normalizedData;

      if (Array.isArray(data)) {
        normalizedData = data.map(record => ({ id: record.id, type: record.type }));
      } else if (data && data.id) {
        normalizedData = { id: data.id, type: data.type };
      } else {
        normalizedData = null;
      }

      newState = immutable.set(
        newState,
        [name, JSON.stringify(params), 'response'],
        normalizedData,
      );

      if (meta) {
        newState = immutable.set(
          newState,
          [name, JSON.stringify(params), 'meta'],
          meta
        );
      }
    }

    newState = immutable.set(
      newState,
github cantierecreativo / redux-bees / src / reducers / requests.js View on Github external
const invalidate = (state, actionName, key) => (
  immutable.set(state, [actionName, key, 'invalid'], true)
);
github cantierecreativo / redux-bees / src / reducers / requests.js View on Github external
newState,
      [name, JSON.stringify(params), 'isLoading'],
      false,
    );

    return newState;
  } else if (metaType === 'error') {
    let newState = state;

    newState = immutable.set(
      newState,
      [name, JSON.stringify(params), 'isLoading'],
      false,
    );

    newState = immutable.set(
      newState,
      [name, JSON.stringify(params), 'response'],
      null,
    );

    if (action.payload instanceof Error) {

      newState = immutable.set(
        newState,
        [name, JSON.stringify(params), 'error'],
        action.payload.message
      );

      newState = immutable.del(
        newState,
        [name, JSON.stringify(params), 'headers'],
github elastic / kibana / x-pack / plugins / canvas / public / state / reducers / transient.js View on Github external
[transientActions.setFirstLoad]: (transientState, { payload }) => {
      return set(transientState, 'isFirstLoad', Boolean(payload));
    },
github htmlburger / carbon-fields / assets / js / fields / reducer.js View on Github external
	[switchComplexTab]: (state, { payload: { fieldId, groupId } }) => immutable.set(state, `${fieldId}.ui.current_tab`, groupId),
}, {}));
github elastic / kibana / x-pack / plugins / canvas / public / state / reducers / pages.js View on Github external
[actions.stylePage]: (workpadState, { payload }) => {
      const pageIndex = workpadState.pages.findIndex(page => page.id === payload.pageId);
      return set(workpadState, ['pages', pageIndex, 'style'], payload.style);
    },
github elastic / kibana / x-pack / plugins / canvas / public / state / reducers / pages.js View on Github external
[actions.setPageTransition]: (workpadState, { payload }) => {
      const pageIndex = workpadState.pages.findIndex(page => page.id === payload.pageId);
      return set(workpadState, ['pages', pageIndex, 'transition'], payload.transition);
    },
  },
github redux-json-api / redux-json-api / src / state-mutation.js View on Github external
export const updateOrInsertResource = (state, resource) => {
  if (typeof resource !== 'object') {
    return state;
  }

  let newState = state;
  const updatePath = [resource.type, 'data'];

  if (stateContainsResource(state, resource)) {
    const resources = state[resource.type].data;
    const idx = resources.findIndex(item => item.id === resource.id);

    if (!equal(resources[idx], resource)) {
      newState = imm.set(newState, updatePath.concat(idx), resource);
    }
  } else {
    newState = imm.push(newState, updatePath, resource);
  }

  const rels = resource.relationships;

  if (!rels) {
    return newState;
  }

  Object.keys(rels).forEach(relKey => {
    if (!hasOwnProperties(rels[relKey], ['data', 'type'])) {
      return;
    }
github cantierecreativo / redux-bees / src / reducers / entities.js View on Github external
newState = items.reduce((acc, item) => (
      immutable.set(
        acc,
        [item.type, item.id],
        item,
      )
    ), newState);

object-path-immutable

Modify deep object properties without modifying the original object (immutability). Works great with React and Redux.

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis