本文整理汇总了TypeScript中rxjs/operators.publishLast函数的典型用法代码示例。如果您正苦于以下问题:TypeScript publishLast函数的具体用法?TypeScript publishLast怎么用?TypeScript publishLast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了publishLast函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getContributors
private getContributors() {
const contributors = this.http.get<{[key: string]: Contributor}>(contributorsPath).pipe(
// Create group map
map(contribs => {
const contribMap: { [name: string]: Contributor[]} = {};
Object.keys(contribs).forEach(key => {
const contributor = contribs[key];
contributor.groups.forEach(group => {
const contribGroup = contribMap[group] || (contribMap[group] = []);
contribGroup.push(contributor);
});
});
return contribMap;
}),
// Flatten group map into sorted group array of sorted contributors
map(cmap => {
return Object.keys(cmap).map(key => {
const order = knownGroups.indexOf(key);
return {
name: key,
order: order === -1 ? knownGroups.length : order,
contributors: cmap[key].sort(compareContributors)
} as ContributorGroup;
})
.sort(compareGroups);
}),
publishLast(),
);
(contributors as ConnectableObservable<ContributorGroup[]>).connect();
return contributors;
}
开发者ID:Cammisuli,项目名称:angular,代码行数:35,代码来源:contributor.service.ts
示例2: getVersionInfo
private getVersionInfo(navigationInfo: Observable<NavigationResponse>) {
const versionInfo = navigationInfo.pipe(
map(response => response.__versionInfo),
publishLast(),
);
(versionInfo as ConnectableObservable<VersionInfo>).connect();
return versionInfo;
}
开发者ID:baconwaffles,项目名称:angular,代码行数:8,代码来源:navigation.service.ts
示例3: it
it('should accept empty parameter', () => {
// Here, TypeScript versions 3.1 and earlier infer Observable<any>. However,
// the next version infers Observable<number>. It's not possible to specify
// an upper bound for the TypeScript version used by dtslint, so an
// expectation cannot be applied.
// TODO: put the test back after Typescript > 3.2
const a = of(1, 2, 3).pipe(publishLast());
});
开发者ID:jaychsu,项目名称:RxJS,代码行数:8,代码来源:publishLast-spec.ts
示例4: getCategories
private getCategories(): Observable<Category[]> {
const categories = this.http.get<any>(resourcesPath).pipe(
map(data => mkCategories(data)),
publishLast(),
);
(categories as ConnectableObservable<Category[]>).connect();
return categories;
};
开发者ID:DallanQ,项目名称:rxjs,代码行数:10,代码来源:resource.service.ts
示例5: getNavigationViews
private getNavigationViews(navigationInfo: Observable<NavigationResponse>): Observable<NavigationViews> {
const navigationViews = navigationInfo.pipe(
map(response => {
const views = Object.assign({}, response);
Object.keys(views).forEach(key => {
if (key[0] === '_') { delete views[key]; }
});
return views as NavigationViews;
}),
publishLast(),
);
(navigationViews as ConnectableObservable<NavigationViews>).connect();
return navigationViews;
}
开发者ID:baconwaffles,项目名称:angular,代码行数:14,代码来源:navigation.service.ts
示例6: fetchNavigationInfo
/**
* Get an observable that fetches the `NavigationResponse` from the server.
* We create an observable by calling `http.get` but then publish it to share the result
* among multiple subscribers, without triggering new requests.
* We use `publishLast` because once the http request is complete the request observable completes.
* If you use `publish` here then the completed request observable will cause the subscribed observables to complete too.
* We `connect` to the published observable to trigger the request immediately.
* We could use `.refCount` here but then if the subscribers went from 1 -> 0 -> 1 then you would get
* another request to the server.
* We are not storing the subscription from connecting as we do not expect this service to be destroyed.
*/
private fetchNavigationInfo(): Observable<NavigationResponse> {
const navigationInfo = this.http.get<NavigationResponse>(navigationPath)
.pipe(publishLast());
(navigationInfo as ConnectableObservable<NavigationResponse>).connect();
return navigationInfo;
}
开发者ID:baconwaffles,项目名称:angular,代码行数:17,代码来源:navigation.service.ts
示例7:
export function publishLast<T>(this: Observable<T>): ConnectableObservable<T> {
//TODO(benlesh): correct type-flow through here.
return higherOrder<T>()(this) as ConnectableObservable<T>;
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:4,代码来源:publishLast.ts
注:本文中的rxjs/operators.publishLast函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论