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


TypeScript store.createSelector函数代码示例

本文整理汇总了TypeScript中@ngrx/store.createSelector函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createSelector函数的具体用法?TypeScript createSelector怎么用?TypeScript createSelector使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: setCollectionSelectors

 function createHeroSidekickSelector$(heroId: number): Observable<Sidekick> {
   const { selectHeroMap, selectSidekickMap } = setCollectionSelectors();
   const selectHero = createSelector(selectHeroMap, heroes => heroes[heroId]);
   const selectSideKick = createSelector(selectHero, selectSidekickMap, (hero, sidekicks) => {
     const sidekickId = hero && hero.sidekickFk;
     return sidekicks[sidekickId];
   });
   return store.select(selectSideKick);
 }
开发者ID:RajeevSingh273,项目名称:angular-ngrx-data,代码行数:9,代码来源:related-entity-selectors.spec.ts

示例2: it

    it('should recursively release ancestor selectors', () => {
      const grandparent = createSelector([incrementOne], a => a);
      const parent = createSelector([grandparent], a => a);
      const child = createSelector([parent], a => a);
      spyOn(grandparent, 'release').and.callThrough();
      spyOn(parent, 'release').and.callThrough();

      child.release();

      expect(grandparent.release).toHaveBeenCalled();
      expect(parent.release).toHaveBeenCalled();
    });
开发者ID:WinGood,项目名称:platform,代码行数:12,代码来源:selector.spec.ts

示例3: getSelectors

  function getSelectors(
    selectState?: (state: any) => EntityState<T>
  ): EntitySelectors<T, any> {
    const selectIds = (state: any) => state.ids;
    const selectEntities = (state: EntityState<T>) => state.entities;
    const selectAll = createSelector(
      selectIds,
      selectEntities,
      (ids: T[], entities: Dictionary<T>): any =>
        ids.map((id: any) => (entities as any)[id])
    );

    const selectTotal = createSelector(selectIds, ids => ids.length);

    if (!selectState) {
      return {
        selectIds,
        selectEntities,
        selectAll,
        selectTotal,
      };
    }

    return {
      selectIds: createSelector(selectState, selectIds),
      selectEntities: createSelector(selectState, selectEntities),
      selectAll: createSelector(selectState, selectAll),
      selectTotal: createSelector(selectState, selectTotal),
    };
  }
开发者ID:AlexChar,项目名称:platform,代码行数:30,代码来源:state_selectors.ts


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