How to use the immutadot.set 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 NarHakobyan / socket-io-client / src / app / core / reducers / emitter-tabs.reducer.ts View on Github external
export function emitterTabsReducer(state: Tabs = initialState, action: EmitterTabsActions.All) {
    switch (action.type) {
      case EmitterTabsActions.ADD:
        return push(state, 'tabs', {index: state.tabs.length, name: action.payload.name, emitName: '', emitBody: {}});
      case EmitterTabsActions.REMOVE:
        return splice(state, 'tabs', action.payload.index, 1);
      case EmitterTabsActions.SELECT_TAB:
        return set(state, 'selectedTabIndex', action.payload.index);
      case EmitterTabsActions.CHANGE_EMIT_NAME:
        return set(state, `tabs[${action.payload.tabIndex}].emitName`, action.payload.name);
      case EmitterTabsActions.CHANGE_EMIT_BODY:
        return set(state, `tabs[${action.payload.tabIndex}].emitBody`, action.payload.body);
      case EmitterTabsActions.REMOVE_ALL:
        return cloneDeep(initialState);
      case EmitterTabsActions.CHANGE_STATE:
        return cloneDeep(action.payload);
      default:
        return state;

    }
  }
}
github NarHakobyan / socket-io-client / src / app / core / reducers / socket-app.reducer.ts View on Github external
export function socketAppReducer(state: SocketApp = initialState, action: SocketAppActions.All) {
    switch (action.type) {
      case SocketAppActions.SET_CONNECT_URL:
        return set(state, 'connectUrl', action.payload.connectUrl);
      case SocketAppActions.REMOVE_CONNECT_URL:
        return set(state, 'connectUrl', '');
      default:
        return state;

    }
  }
}
github NarHakobyan / socket-io-client / src / app / core / reducers / emitter-tabs.reducer.ts View on Github external
export function emitterTabsReducer(state: Tabs = initialState, action: EmitterTabsActions.All) {
    switch (action.type) {
      case EmitterTabsActions.ADD:
        return push(state, 'tabs', {index: state.tabs.length, name: action.payload.name, emitName: '', emitBody: {}});
      case EmitterTabsActions.REMOVE:
        return splice(state, 'tabs', action.payload.index, 1);
      case EmitterTabsActions.SELECT_TAB:
        return set(state, 'selectedTabIndex', action.payload.index);
      case EmitterTabsActions.CHANGE_EMIT_NAME:
        return set(state, `tabs[${action.payload.tabIndex}].emitName`, action.payload.name);
      case EmitterTabsActions.CHANGE_EMIT_BODY:
        return set(state, `tabs[${action.payload.tabIndex}].emitBody`, action.payload.body);
      case EmitterTabsActions.REMOVE_ALL:
        return cloneDeep(initialState);
      case EmitterTabsActions.CHANGE_STATE:
        return cloneDeep(action.payload);
      default:
        return state;

    }
  }
}
github NarHakobyan / socket-io-client / src / app / core / reducers / emitter-tabs.reducer.ts View on Github external
export function emitterTabsReducer(state: Tabs = initialState, action: EmitterTabsActions.All) {
    switch (action.type) {
      case EmitterTabsActions.ADD:
        return push(state, 'tabs', {index: state.tabs.length, name: action.payload.name, emitName: '', emitBody: {}});
      case EmitterTabsActions.REMOVE:
        return splice(state, 'tabs', action.payload.index, 1);
      case EmitterTabsActions.SELECT_TAB:
        return set(state, 'selectedTabIndex', action.payload.index);
      case EmitterTabsActions.CHANGE_EMIT_NAME:
        return set(state, `tabs[${action.payload.tabIndex}].emitName`, action.payload.name);
      case EmitterTabsActions.CHANGE_EMIT_BODY:
        return set(state, `tabs[${action.payload.tabIndex}].emitBody`, action.payload.body);
      case EmitterTabsActions.REMOVE_ALL:
        return cloneDeep(initialState);
      case EmitterTabsActions.CHANGE_STATE:
        return cloneDeep(action.payload);
      default:
        return state;

    }
  }
}
github bpetetot / conference-hall / src / store / reactions / talks.js View on Github external
export const updateSpeakerToTalk = async (action, store) => {
  const { uid, talkId } = action.payload
  const talk = store.data.talks.get(talkId)
  if (talk) {
    let updated
    if (action.type === '@@ui/ADD_SPEAKER_TO_TALK') {
      updated = set(talk, `speakers.${uid}`, true)
    } else if (action.type === '@@ui/REMOVE_SPEAKER_TO_TALK') {
      updated = unset(talk, `speakers.${uid}`)
    }
    if (updated && Object.keys(updated.speakers).length > 0) {
      await talkCrud.update(updated)
      store.data.talks.update(updated)
    }
  }
}
github bpetetot / conference-hall / src / components / calendar / monthCalendar / monthCalendar.jsx View on Github external
function generateWeeksForMonth(date) {
  const startDay = getDay(startOfMonth(date))

  const weeks = chunk(
    [...Array(startDay).fill(null), ...range(getDaysInMonth(date)).map(add(1))],
    7,
  )

  const lastWeek = weeks[weeks.length - 1]
  const fillOffset = 7 - lastWeek.length

  return set(weeks, weeks.length - 1, [...lastWeek, ...Array(fillOffset).fill(null)])
}
github NarHakobyan / socket-io-client / src / app / core / reducers / progress-bar.reducer.ts View on Github external
export function progressBarReducer(state: ProgressBarState = initialState, action: ProgressBarActions.All) {
    switch (action.type) {
      case ProgressBarActions.SHOW:
        return set(state, 'show', true);
      case ProgressBarActions.HIDE:
        return set(state, 'show', false);
      default:
        return state;

    }
  }
}
github zenika-open-source / FAQ / src / scenes / Auth / reducer.js View on Github external
export const reducer = (state = initialState, action) => {
  switch (action.type) {
  case LOGIN_ERROR:
    return set(state, 'error', action.error)
  default:
    return state
  }
}
github zenika-open-source / FAQ / src / reducers / questions.js View on Github external
const search = (state = initialState, action) => {
  switch (action.type) {
  case types.SEARCH:
    const filtered = new Fuse(state.questions, fuseOptions)
      .search(action.text)
      .filter(q => q.score < fuseOptions.threshold)
    return set(state, 'filtered', filtered)
  case types.CLEAR_SEARCH:
    return set(state, 'filtered', [])
  default:
    return state
  }
}