當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。