本文整理匯總了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)
);
}
示例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]));
}
示例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]));
};
示例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]);
}
示例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]));
}
示例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]);
}
示例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);
};
示例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]));
}