本文整理汇总了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]));
}