本文整理汇总了TypeScript中rxjs/operator/last.last类的典型用法代码示例。如果您正苦于以下问题:TypeScript last类的具体用法?TypeScript last怎么用?TypeScript last使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了last类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: forEach
export function waitForMap<A, B>(
obj: {[k: string]: A}, fn: (k: string, a: A) => Observable<B>): Observable<{[k: string]: B}> {
const waitFor: Observable<B>[] = [];
const res: {[k: string]: B} = {};
forEach(obj, (a: A, k: string) => {
if (k === PRIMARY_OUTLET) {
waitFor.push(map.call(fn(k, a), (_: B) => {
res[k] = _;
return _;
}));
}
});
forEach(obj, (a: A, k: string) => {
if (k !== PRIMARY_OUTLET) {
waitFor.push(map.call(fn(k, a), (_: B) => {
res[k] = _;
return _;
}));
}
});
if (waitFor.length > 0) {
const concatted$ = concatAll.call(of (...waitFor));
const last$ = l.last.call(concatted$);
return map.call(last$, () => res);
} else {
return of (res);
}
}
示例2: of
export function waitForMap<A, B>(
obj: {[k: string]: A}, fn: (k: string, a: A) => Observable<B>): Observable<{[k: string]: B}> {
if (Object.keys(obj).length === 0) {
return of ({})
}
const waitHead: Observable<B>[] = [];
const waitTail: Observable<B>[] = [];
const res: {[k: string]: B} = {};
forEach(obj, (a: A, k: string) => {
const mapped = map.call(fn(k, a), (r: B) => res[k] = r);
if (k === PRIMARY_OUTLET) {
waitHead.push(mapped);
} else {
waitTail.push(mapped);
}
});
const concat$ = concatAll.call(of (...waitHead, ...waitTail));
const last$ = l.last.call(concat$);
return map.call(last$, () => res);
}