當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript rxjs.forkJoin函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。