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

TypeScript rxjs.forkJoin函数代码示例

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

本文整理汇总了TypeScript中rxjs.forkJoin函数的典型用法代码示例。如果您正苦于以下问题:TypeScript forkJoin函数的具体用法?TypeScript forkJoin怎么用?TypeScript forkJoin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了forkJoin函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: type

 type('should support arrays of observables', () => {
   /* tslint:disable:no-unused-variable */
   let a: Observable<number>[];
   let o1: Observable<number[]> = forkJoin(a);
   let o2: Observable<number[]> = forkJoin(...a);
   /* tslint:enable:no-unused-variable */
 });
开发者ID:DallanQ,项目名称:rxjs,代码行数:7,代码来源:forkJoin-spec.ts


示例2: dispatchByEvents

 private dispatchByEvents(actionOrActions: any | any[]): Observable<any> {
   if (Array.isArray(actionOrActions)) {
     return forkJoin(actionOrActions.map(a => this.dispatchSingle(a)));
   } else {
     return this.dispatchSingle(actionOrActions);
   }
 }
开发者ID:LucasFrecia,项目名称:store,代码行数:7,代码来源:dispatcher.ts


示例3: Observable

 return new Observable((observer) => {
     forkJoin(
         involvedObservable,
         myTaskObservable,
         queuedObservable,
         completeObservable
     ).subscribe(
         (res) => {
             let filters: FilterRepresentationModel[] = [];
             res.forEach((filter) => {
                 if (filter.name === involvedTasksFilter.name) {
                     involvedTasksFilter.id = filter.id;
                     filters.push(involvedTasksFilter);
                 } else if (filter.name === myTasksFilter.name) {
                     myTasksFilter.id = filter.id;
                     filters.push(myTasksFilter);
                 } else if (filter.name === queuedTasksFilter.name) {
                     queuedTasksFilter.id = filter.id;
                     filters.push(queuedTasksFilter);
                 } else if (filter.name === completedTasksFilter.name) {
                     completedTasksFilter.id = filter.id;
                     filters.push(completedTasksFilter);
                 }
             });
             observer.next(filters);
             observer.complete();
         },
         (err: any) => {
             this.logService.error(err);
         });
 });
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:31,代码来源:task-filter.service.ts


示例4: getModules

  getModules(): Observable<Module[]> {
    if (!this.modulesCache$) {
      this.modulesCache$ = forkJoin(
        this.configService.getModules(), // names of the enabled modules
        this.toolResource.getModules() // all modules from the server
      ).pipe(
        map(results => {
          const enabledModules: string[] = results[0];
          const allModules: Module[] = results[1];
          return allModules
            .filter(
              (module: Module) => enabledModules.indexOf(module.name) >= 0
            )
            .map((module: Module) => {
              // set moduleId
              module.moduleId = module.name.toLowerCase();

              // create categoriesMap
              module.categoriesMap = UtilsService.arrayToMap(
                module.categories,
                "name"
              );

              return module;
            });
        }),
        shareReplay(1)
      );
    }
    return this.modulesCache$;
  }
开发者ID:chipster,项目名称:chipster-web,代码行数:31,代码来源:tools.service.ts


示例5: async

    async(inject([HttpInterceptorService, MockBackend], (service: HttpInterceptorService, mockBackend: MockBackend) => {
      mockBackend.connections.subscribe((connection: MockConnection) => {
        connection.mockRespond(new Response(new ResponseOptions({
            status: 200,
            body: JSON.stringify('success')},
        )));
      });
      let success: boolean = false;
      let error: boolean = false;
      let complete: boolean = false;

      forkJoin(
        service.get('testurl'),
        service.get('testurl'))
      .subscribe((response: Response[]) => {
        success = true;
      }, () => {
        error = true;
      }, () => {
        complete = true;
      });

      expect(success).toBe(true, 'on success didnt execute with observables');
      expect(error).toBe(false, 'on error executed when it shouldnt have with observables');
      expect(complete).toBe(true, 'on complete didnt execute with observables');
    }),
开发者ID:Teradata,项目名称:covalent,代码行数:26,代码来源:http-interceptor.service.spec.ts


示例6: forkJoin1

  forkJoin1() {
    const myPromise = val =>
      new Promise(resolve =>
        setTimeout(() => resolve(`Promise Resolved: ${val}`), 5000)
      );

    /*
      when all observables complete, give the last
      emitted value from each as an array
    */
    const example = forkJoin(
      // emit 'Hello' immediately
      of('Hello'),
      // emit 'World' after 1 second
      of('World').pipe(delay(1000)),
      // emit 0 after 1 second
      interval(1000).pipe(take(1)),
      // emit 0...1 in 1 second interval
      interval(1000).pipe(take(2)),
      // promise that resolves to 'Promise Resolved' after 5 seconds
      myPromise('RESULT')
    );
    // output: ["Hello", "World", 0, 1, "Promise Resolved: RESULT"]
    const subscribe = example.subscribe(val => console.log(val));
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:25,代码来源:combining.service.ts


示例7: Observable

 return new Observable((observer) => {
     forkJoin(
         runningObservable,
         completedObservable,
         allObservable
     ).subscribe(
         (res) => {
             let filters: FilterProcessRepresentationModel[] = [];
             res.forEach((filter) => {
                 if (filter.name === runningFilter.name) {
                     runningFilter.id = filter.id;
                     filters.push(runningFilter);
                 } else if (filter.name === completedFilter.name) {
                     completedFilter.id = filter.id;
                     filters.push(completedFilter);
                 } else if (filter.name === allFilter.name) {
                     allFilter.id = filter.id;
                     filters.push(allFilter);
                 }
             });
             observer.next(filters);
             observer.complete();
         },
         (err: any) => {
             this.handleProcessError(err);
         });
 });
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:27,代码来源:process-filter.service.ts


示例8: it

  it('should accept array of observable contains single', () => {
    const e1 = forkJoin(
               [hot('--a--b--c--d--|')]
            );
    const expected = '--------------(x|)';

    expectObservable(e1).toBe(expected, {x: ['d']});
  });
开发者ID:DallanQ,项目名称:rxjs,代码行数:8,代码来源:forkJoin-spec.ts



注:本文中的rxjs.forkJoin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript rxjs.from函数代码示例发布时间:2022-05-25
下一篇:
TypeScript rxjs.empty函数代码示例发布时间: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