How to use the immutability-helper.default function in immutability-helper

To help you get started, we’ve selected a few immutability-helper 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 bwsw / cloudstack-ui / src / app / resource-quotas / redux / resource-quotas-admin-form.reducer.ts View on Github external
export function resourceQuotasAdminFormReducer(
  state = initialState,
  action: resourceQuotasActions.Actions,
): ResourceQuotasAdminFormState {
  switch (action.type) {
    case resourceQuotasActions.ResourceQuotasActionTypes.UPDATE_ADMIN_FORM_FIELD: {
      const resourceType = action.payload.resourceType;

      return update(state, {
        form: {
          [resourceType]: {
            $merge: omit(action.payload, 'resourceType'),
          },
        },
      });
    }

    case resourceQuotasActions.ResourceQuotasActionTypes.UPDATE_ADMIN_FORM: {
      return {
        ...state,
        form: action.payload,
      };
    }

    case resourceQuotasActions.ResourceQuotasActionTypes.UPDATE_RESOURCE_QUOTAS_REQUEST: {
github tomchentw / react-toastr / src / lib / ToastContainer.js View on Github external
optionsOverride.handleOnClick();
          }
          return this._handle_toast_on_click(e);
        },
        handleRemove: this._handle_toast_remove,
      },
    });
    const toastOperation = {
      [`${this.props.newestOnTop ? `$unshift` : `$push`}`]: [newToast],
    };

    const messageOperation = {
      [`${this.props.newestOnTop ? `$unshift` : `$push`}`]: [message],
    };

    const nextState = update(this.state, {
      toasts: toastOperation,
      messageList: messageOperation,
    });
    this.setState(nextState);
  }
github tomchentw / react-toastr / src / lib / ToastContainer.js View on Github external
_notify(type, message, title, optionsOverride = {}) {
    if (this.props.preventDuplicates) {
      if (_.includes(this.state.messageList, message)) {
        return;
      }
    }
    const key = this.state.toastId++;
    const toastId = key;
    const newToast = update(optionsOverride, {
      $merge: {
        type,
        title,
        message,
        toastId,
        key,
        ref: `toasts__${key}`,
        handleOnClick: (e) => {
          if (`function` === typeof optionsOverride.handleOnClick) {
            optionsOverride.handleOnClick();
          }
          return this._handle_toast_on_click(e);
        },
        handleRemove: this._handle_toast_remove,
      },
    });
github bwsw / cloudstack-ui / src / app / resource-quotas / redux / resource-quotas-user-form.reducer.ts View on Github external
...state.limits,
          [resourceType]: action.payload.limit,
        },
      };
    }

    case resourceQuotasActions.ResourceQuotasActionTypes.UPDATE_USER_FORM_QUOTAS: {
      return update(state, {
        $merge: {
          quotas: action.payload,
        },
      });
    }

    case resourceQuotasActions.ResourceQuotasActionTypes.UPDATE_USER_FORM_LIMITS: {
      return update(state, {
        $merge: {
          limits: mapValues(action.payload, 'max'),
        },
      });
    }

    default:
      return state;
  }
}
github tomchentw / react-toastr / src / lib / ToastContainer.js View on Github external
this.state.toasts[operationName]((found, toast, index) => {
      if (found || toast.toastId !== toastId) {
        return false;
      }
      this.setState(update(this.state, {
        toasts: { $splice: [[index, 1]] },
        messageList: { $splice: [[index, 1]] },
      }));
      return true;
    }, false);
  }

immutability-helper

mutate a copy of data without changing the original source

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis