How to use the object-path-immutable.assign 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 elastic / kibana / x-pack / plugins / canvas / public / state / reducers / elements.js View on Github external
function assignElementProperties(workpadState, pageId, elementId, props) {
  const pageIndex = getPageIndexById(workpadState, pageId);
  const elementsPath = ['pages', pageIndex, 'elements'];
  const elementIndex = get(workpadState, elementsPath, []).findIndex(
    element => element.id === elementId
  );

  if (pageIndex === -1 || elementIndex === -1) {
    return workpadState;
  }

  // remove any AST value from the element caused by https://github.com/elastic/kibana-canvas/issues/260
  // TODO: remove this after a bit of time
  const cleanWorkpadState = del(workpadState, elementsPath.concat([elementIndex, 'ast']));

  return assign(cleanWorkpadState, elementsPath.concat(elementIndex), props);
}
github htmlburger / carbon-fields / assets / js / fields / reducer.js View on Github external
	[updateField]: (state, { payload: { fieldId, data }}) => immutable.assign(state, fieldId, data),
github htmlburger / carbon-fields / assets / js / fields / reducer.js View on Github external
	[markFieldAsInvalid]: (state, { payload: { fieldId, error } }) => immutable.assign(state, `${fieldId}.ui`, {
		valid: false,
		error: error,
	}),
github htmlburger / carbon-fields / assets / js / fields / reducer.js View on Github external
	[combineActions(setupField, setUI)]:  (state, { payload: { fieldId, ui }}) => immutable.assign(state, `${fieldId}.ui`, ui),
github elastic / kibana / x-pack / plugins / canvas / public / state / reducers / assets.js View on Github external
[setAssetValue]: (assetState, { payload }) => {
      const { id, value } = payload;
      const asset = get(assetState, [id]);
      if (!asset) {
        throw new Error(`Can not set asset data, id not found: ${id}`);
      }
      return assign(assetState, id, { value });
    },

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