How to use the immutadot/core/set.unset function in immutadot

To help you get started, we’ve selected a few immutadot 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 Zenika / marcel / backoffice / src / clients / reducer.js View on Github external
const clients = (state = initialState, action) => {
  switch (action.type) {
    case loadersActions.LOAD_CLIENTS_SUCCESSED: {
      return { ...state, clients: action.payload.clients }
    }
    case actions.CLIENT_ASSOCIATION_STARTED: {
      return set(state, `loading.${action.payload.client.id}`, true)
    }
    case actions.CLIENT_ASSOCIATION_SUCCESS: {
      const { client } = action.payload
      return flow(
        unset(`loading.${client.id}`),
        set(`clients.${client.id}`, client),
      )(state)
    }
    case actions.CLIENT_ASSOCIATION_FAILED: {
      const { client } = action.payload
      return unset(state, `loading.${client.id}`)
    }
    case actions.REQUIRE_CLIENT_ASSOCIATION: {
      const { client } = action.payload
      return { ...state, associating: client }
    }
    case actions.CONFIRM_CLIENT_ASSOCIATION:
    case actions.CANCEL_CLIENT_ASSOCIATION: {
      return { ...state, associating: null }
    }
    default:
github Zenika / marcel / backoffice / src / clients / reducer.js View on Github external
case loadersActions.LOAD_CLIENTS_SUCCESSED: {
      return { ...state, clients: action.payload.clients }
    }
    case actions.CLIENT_ASSOCIATION_STARTED: {
      return set(state, `loading.${action.payload.client.id}`, true)
    }
    case actions.CLIENT_ASSOCIATION_SUCCESS: {
      const { client } = action.payload
      return flow(
        unset(`loading.${client.id}`),
        set(`clients.${client.id}`, client),
      )(state)
    }
    case actions.CLIENT_ASSOCIATION_FAILED: {
      const { client } = action.payload
      return unset(state, `loading.${client.id}`)
    }
    case actions.REQUIRE_CLIENT_ASSOCIATION: {
      const { client } = action.payload
      return { ...state, associating: client }
    }
    case actions.CONFIRM_CLIENT_ASSOCIATION:
    case actions.CANCEL_CLIENT_ASSOCIATION: {
      return { ...state, associating: null }
    }
    default:
      return state
  }
}