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


TypeScript EntityAdapter.removeAll方法代码示例

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


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

示例1: reducer

export function reducer(state = initialState, action: WidgetActions): State {
  switch (action.type) {
    case WidgetActionTypes.DATABASE_LISTEN_FOR_DATA_STOP: {
      return adapter.removeAll({
        ...state,
        loaded: false,
        loading: false,
        selectedWidgetId: '',
      });
    }

    case WidgetActionTypes.LOAD_SUCCESS: {
      return adapter.addAll(action.payload.items, state);
    }

    default: {
      return state;
    }
  }
}
开发者ID:tja4472,项目名称:ngrx-ionic-angularfire,代码行数:20,代码来源:widget.reducer.ts

示例2: reducer

export function reducer(
    state = initialState,
    action: ArticlesActions
): State {
    switch (action.type) {
        case ArticlesActionTypes.LoadArticle: {
            return {
                ...state,
                selectedArticleId: state.selectedArticleId,
                selectedArticle: null
            };
        }

        case ArticlesActionTypes.Load: {
            return adapter.removeAll({
                ...state,
            });
        }

        case ArticlesActionTypes.LoadSuccess: {
            return adapter.addMany(action.payload.articles, {
                ...state,
                selectedArticleId: null,
                selectedArticle: null,
            } as State);
        }

        case ArticlesActionTypes.LoadFail: {
            return Object.assign({}, {
                ...state
            } as State);
        }

        case ArticlesActionTypes.ChangePage: {
            const index = action.payload;
            const start = index * state.page.pageSize;

            return {
                ...state,
                page: {
                    pageIndex: index,
                    pageSize: state.page.pageSize,
                    startIndex: start,
                    endIndex: start + state.page.pageSize
                } as Page
            };
        }

        case ArticlesActionTypes.SelectArticle: {
            return {
                ...state,
                selectedArticleId: action.payload,
                selectedArticle: null
            };
        }

        case ArticlesActionTypes.SelectArticleSuccess: {
            return {
                ...state,
                selectedArticleId: state.selectedArticleId,
                selectedArticle: action.payload.article
            };
        }

        case ArticlesActionTypes.SelectArticleFail: {
            return {
                ...state
            };
        }

        default: {
            return state;
        }
    }
}
开发者ID:evcraddock,项目名称:erikvancraddock.com,代码行数:75,代码来源:articles.ts

示例3: reducer

export function reducer(state = initialState, action: GizmoActions): State {
  switch (action.type) {
    case GizmoActionTypes.DATABASE_LISTEN_FOR_DATA_START: {
      return {
        ...state,
        loading: true,
      };
    }

    case GizmoActionTypes.DATABASE_LISTEN_FOR_DATA_STOP: {
      return adapter.removeAll({
        ...state,
        loaded: false,
        loading: false,
        selectedGizmoId: '',
      });
    }

    /*
    case GizmoActionTypes.ADD_GIZMO: {
      return adapter.addOne(action.payload.gizmo, state);
    }

    case GizmoActionTypes.ADD_GIZMOS: {
      return adapter.addMany(action.payload.gizmos, state);
    }

    case GizmoActionTypes.UPDATE_GIZMO: {
      return adapter.updateOne(action.payload.gizmo, state);
    }
*/
    case GizmoActionTypes.STORE_ADD_ITEMS: {
      return {
        ...adapter.addMany(action.payload.gizmos, state),
        loaded: true,
        loading: false,
      };
    }

    case GizmoActionTypes.STORE_DELETE_ITEMS: {
      return adapter.removeMany(action.payload.ids, state);
    }

    case GizmoActionTypes.STORE_UPDATE_ITEMS: {
      return adapter.updateMany(action.payload.items, state);
    }
    /*
    case GizmoActionTypes.DELETE_GIZMO: {
      return adapter.removeOne(action.payload.id, state);
    }

    case GizmoActionTypes.LOAD_GIZMOS: {
      return adapter.addAll(action.payload.gizmos, state);
    }

    case GizmoActionTypes.CLEAR_GIZMOS: {
      return adapter.removeAll({ ...state, selectedGizmoId: '' });
    }
*/
    default: {
      return state;
    }
  }
}
开发者ID:tja4472,项目名称:ngrx-ionic-angularfire,代码行数:64,代码来源:gizmo.reducer.ts


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