• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript operators.publishLast函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript operators.publishReplay函数代码示例发布时间:2022-05-25
下一篇:
TypeScript operators.publish函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap