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


TypeScript combineLatest.combineLatest函数代码示例

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


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

示例1: checkStore

  checkStore(id: number): Observable<boolean> {
    const loaded$: Observable<boolean> = this.store.select(
      fromSelectors.getHeroesLoaded
    );
    const selectedHeroId$: Observable<number> = this.store.select(
      fromSelectors.getSelectedHeroId
    );

    return combineLatest(loaded$, selectedHeroId$).pipe(
      tap(([loaded, selectedHeroId]) => {
        if (!loaded) {
          this.store.dispatch(new GetHeroes());
        }

        if (!selectedHeroId || selectedHeroId !== id) {
          this.store.dispatch(new GetHeroById(id));
        }
      }),
      filter(
        ([loaded, selectedHeroId]) =>
          loaded && selectedHeroId && selectedHeroId === id
      ),
      map(() => true),
      take(1)
    );
  }
开发者ID:klimentru1986,项目名称:ngrx-toh,代码行数:26,代码来源:selected-hero.guard.ts

示例2: getPosts

export function getPosts(posts$: Observable<Posts>){
	return combineLatest<{ [id: string]: Post }, string[]>(
	  	posts$.let(getPostEntities),
	  	posts$.let(getPostIds)
  	)
    .map(([ entities, ids ]) => ids.map(id => entities[id]));
}
开发者ID:bkirby989,项目名称:WallaceTheme,代码行数:7,代码来源:posts.selectors.ts

示例3: function

export const getCubeCollection = function (state$: Observable<State>) {
  return combineLatest<{ [name: string]: Cube }, string[]>(
    state$.let(getCubeEntities),
    state$.let(getCollectionCubeIds)
  )
    .map(([entities, ids]) => ids.map(name => entities[name]));
};
开发者ID:okgreece,项目名称:indigo,代码行数:7,代码来源:index.ts

示例4: getSelectedPage

export function getSelectedPage(pages$: Observable<Pages>){
	return combineLatest<{ [id: string]: Page }, string>(
		pages$.let(getPageEntities),
  		pages$.let(getSelectedPageId)
	)
	.map(([ entities, id ]) => entities[id]);
}
开发者ID:bkirby989,项目名称:WallaceTheme,代码行数:7,代码来源:pages.selectors.ts

示例5: getAllBooks

export function getAllBooks(state$: Observable<State>) {
  return combineLatest<{ [id: string]: Book }, string[]>(
    state$.let(getBookEntities),
    state$.let(getBookIds)
  )
  .map(([ entities, ids ]) => ids.map(id => entities[id]));
}
开发者ID:amikitevich,项目名称:example-app,代码行数:7,代码来源:books.ts

示例6: getSelectedPost

export function getSelectedPost(posts$: Observable<Posts>){
	return combineLatest<{ [id: string]: Post }, string>(
		posts$.let(getPostEntities),
  		posts$.let(getSelectedPostId)
	)
	.map(([ entities, id ]) => entities[id]);
}
开发者ID:bkirby989,项目名称:WallaceTheme,代码行数:7,代码来源:posts.selectors.ts

示例7: function

export const isSelectedBookInCollection = function (state$: Observable<State>) {
  return combineLatest<string[], Book>(
    state$.let(getCollectionBookIds),
    state$.let(getSelectedBook)
  )
  .map(([ ids, selectedBook ]) => ids.indexOf(selectedBook.id) > -1);
};
开发者ID:Lumenss,项目名称:testing-app,代码行数:7,代码来源:index.ts

示例8: getPages

export function getPages(pages$: Observable<Pages>){
	return combineLatest<{ [id: string]: Page }, string[]>(
	  	pages$.let(getPageEntities),
	  	pages$.let(getPageIds)
  	)
    .map(([ entities, ids ]) => ids.map(id => entities[id]));
}
开发者ID:bkirby989,项目名称:WallaceTheme,代码行数:7,代码来源:pages.selectors.ts


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