How to use the immutadot.push 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 / emit-history.reducer.ts View on Github external
export function eventHistoryReducer(state: EmitHistory = initialState, action: EmitHistoryActions.All) {
    switch (action.type) {
      case EmitHistoryActions.ADD:
        const event: IEvent = cloneDeep(action.payload);
        event.created = new Date();
        event.id = generate();
        return push(state, 'events', event);
      case EmitHistoryActions.REMOVE:
        return filter(state, 'events', e => e.id !== this.payload.eventId);
      case EmitHistoryActions.EDIT_PAYLOAD:
        return map(state, 'events', e => {
          if (e.id === action.payload.eventId) {
            return set(e, 'data', action.payload);
          }
          return e;
        });
      case EmitHistoryActions.REMOVE_ALL:
        return set(state, 'events', []);
      case EmitHistoryActions.CHANGE_STATE:
        return cloneDeep(action.payload);
      default:
        return state;