当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript EntityAdapter.removeOne方法代码示例

本文整理汇总了TypeScript中@ngrx/entity.EntityAdapter.removeOne方法的典型用法代码示例。如果您正苦于以下问题:TypeScript EntityAdapter.removeOne方法的具体用法?TypeScript EntityAdapter.removeOne怎么用?TypeScript EntityAdapter.removeOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ngrx/entity.EntityAdapter的用法示例。


在下文中一共展示了EntityAdapter.removeOne方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: reducer

export function reducer(state = initialState, action: skilltree.Actions): State {
  switch (action.type) {
    case skilltree.LOAD_SKILLTREE_SUCCESS:
    case skilltree.COPY_SKILLTREE:
    case skilltree.IMPORT_SKILLTREE_SUCCESS:
    case skilltree.IMPORT_LEGACY_SKILLTREE:
    case skilltree.ADD_SKILLTREE: {
      const skilltree = action.payload;
      return adapter.addOne(skilltree, state);
    }

    case skilltree.REMOVE_SKILLTREE: {
      const skilltree: Skilltree = action.payload;

      let newState;
      if (state.selectedSkilltreeId && state.selectedSkilltreeId == skilltree.id) {
        newState = {...state, selectedSkilltreeId: null};
      } else {
        newState = state;
      }
      return adapter.removeOne(skilltree.id, newState);
    }

    case skilltree.RENAME_SKILLTREE: {
      const oldId = action.oldId;
      const newId = action.newId;

      return adapter.updateOne({changes: {id: newId}, id: oldId}, state);
    }

    case skilltree.UPDATE_SKILLTREE_INFO: {
      const update = action.payload;

      return adapter.updateOne(update, state);
    }

    case skilltree.UPDATE_SKILLTREE_ORDER: {
      const update = action.payload;
      return adapter.updateMany(update, state);
    }

    case skilltree.UPDATE_SKILLTREE_UPGRADE: {
      const update = action.payload;

      return adapter.updateOne(update, state);
    }

    default: {
      return state;
    }
  }
}
开发者ID:xXKeyleXx,项目名称:MyPet-SkilltreeCreator,代码行数:52,代码来源:skilltree.ts

示例2: bookReducer

export function bookReducer(
  state: BookState = initialState,
  action: BookActions
): BookState {
  switch (action.type) {
    case BookActionTypes.UPSERT_ONE:
      return bookAdapter.upsertOne(action.payload.book, state);

    case BookActionTypes.DELETE_ONE:
      return bookAdapter.removeOne(action.payload.id, state);

    default:
      return state;
  }
}
开发者ID:tormentedhollow,项目名称:angular-ngrx-material-starter,代码行数:15,代码来源:books.reducer.ts

示例3: reducer

export function reducer(state = initialState, action: HeroActions): State {
  switch (action.type) {
    case HeroActionTypes.heroGetHeroes:
    case HeroActionTypes.heroAddHero:
    case HeroActionTypes.heroDeleteHero:
    case HeroActionTypes.heroUpdateHero:
    case HeroActionTypes.heroSearchHeroes:
    case HeroActionTypes.heroGetHeroById:
      return {
        ...state,
        loading: true
      };

    case HeroActionTypes.heroGetHeroesSuccess:
      return adapter.addAll(action.payload, {
        ...state,
        loading: false,
        loaded: true
      });

    case HeroActionTypes.heroGetHeroByIdSuccess:
      return { ...state, selectedHeroId: action.payload.id, loading: false };

    case HeroActionTypes.heroAddHeroSuccess:
      return adapter.addOne(action.payload, {
        ...state,
        loading: false,
        loaded: true
      });

    case HeroActionTypes.heroUpdateHeroSuccess: {
      return adapter.updateOne(
        {
          id: action.payload.id,
          changes: action.payload
        },
        {
          ...state,
          loading: false,
          loaded: true
        }
      );
    }

    case HeroActionTypes.heroDeleteHeroSuccess: {
      return adapter.removeOne(action.payload.id, {
        ...state,
        loading: false,
        loaded: true
      });
    }

    case HeroActionTypes.heroSearchHeroesSuccess:
      return {
        ...state,
        searchHeroes: action.payload,
        loading: false
      };

    case HeroActionTypes.heroSearchHeroesReset:
      return {
        ...state,
        searchHeroes: null
      };

    case HeroActionTypes.heroError:
      return {
        ...state,
        loading: false,
        loaded: false,
        error: action.payload
      };

    default:
      return state;
  }
}
开发者ID:klimentru1986,项目名称:ngrx-toh,代码行数:77,代码来源:hero.reducer.ts

示例4: reducer

export function reducer(
  state = initialState,
  action: PlaylistsAction | VideoActions
): PlaylistState {
  switch (action.type) {
    case PlaylistActionTypes.LoadPlaylists: {
      return {
        ...state,
        playlistsLoading: true
      };
    }

    case PlaylistActionTypes.LoadPlaylistsSuccess: {
      return adapter.addAll(action.payload, {
        ...state,
        playlistsLoading: false,
        playlistsLoaded: true
      });
    }

    case PlaylistActionTypes.LoadPlaylistDetails: {
      if (
        state.playlistDetails &&
        state.playlistDetails.id === action.payload
      ) {
        return {
          ...state,
          playlistDetailsLoaded: true
        };
      } else {
        return {
          ...state,
          playlistDetailsLoading: true,
          playlistDetailsLoaded: false
        };
      }
    }

    case PlaylistActionTypes.LoadPlaylistDetailsSuccess: {
      const playlistDetails = action.payload;

      return {
        ...state,
        playlistDetails,
        playlistDetailsLoaded: true,
        playlistDetailsLoading: false
      };
    }

    case PlaylistActionTypes.CreatePlaylistSuccess: {
      const playlist = action.payload;

      return adapter.addOne(playlist, state);
    }

    case PlaylistActionTypes.DeletePlaylist: {
      const playlistId = action.payload;

      return adapter.removeOne(playlistId, state);
    }

    case VideoActionTypes.AddVideoToPlaylist: {
      return {
        ...state,
        entities: {
          ...state.entities,
          [action.payload.playlistId]: {
            ...state.entities[action.payload.playlistId],
            videosCount: ++state.entities[action.payload.playlistId].videosCount
          }
        }
      };
    }

    case VideoActionTypes.RemoveVideoFromPlaylist: {
      return {
        ...state,
        entities: {
          ...state.entities,
          [action.payload.playlistId]: {
            ...state.entities[action.payload.playlistId],
            videosCount: --state.entities[action.payload.playlistId].videosCount
          }
        }
      };
    }

    default:
      return state;
  }
}
开发者ID:ArmyMusicOnline,项目名称:ami,代码行数:91,代码来源:playlist.reducer.ts


注:本文中的@ngrx/entity.EntityAdapter.removeOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。