当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Observable.forkJoin方法代码示例

本文整理汇总了TypeScript中rxjs/Rx.Observable.forkJoin方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.forkJoin方法的具体用法?TypeScript Observable.forkJoin怎么用?TypeScript Observable.forkJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs/Rx.Observable的用法示例。


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

示例1: getProfile

	getProfile(username) {
		this._profileUrl = "https://api.github.com/users/" + username;
		this._followersUrl = "https://api.github.com/users/" + username + "/followers";

		return Observable.forkJoin(
			this._http.get(this._profileUrl).map(res => res.json()),
			this._http.get(this._followersUrl).map(res => res.json())
		)
	}
开发者ID:justinrjoseph,项目名称:angular-2-exercises,代码行数:9,代码来源:github-profile.service.ts

示例2: getImageIDs

 getImageIDs(ids) {
     console.log('ids', ids);
     var books = null;
     var movies = null;
     var obs: any[];
     obs = [];
     for (var i = 0; i < ids.length; i++) {
         obs.push(this.http.get(this.getPhotoURL(ids[i].id)).map((res: Response) => res.json()));
     }
     return Observable.forkJoin(obs);
 }
开发者ID:phifour,项目名称:angular2starter,代码行数:11,代码来源:httptest.service.ts

示例3: loadAll

  loadAll() {
    if (this._store.images.length > 0) return Observable.of(this._store.images);

    Observable.forkJoin(
      this._hat.getAllValuesOf('photos', 'dropbox')
        .map(data => data.map(this.imgMap)),
      this._hat.getAllValuesOf('metadata', 'dropbox_plug')
    ).subscribe(responses => {
      this._store.images = responses[0];
      this._authBearer = "Bearer " + responses[1][0]['access_token'];
      this.downloadImages();
    }, err => console.log('There was an error loading images from HAT', err));
  }
开发者ID:bryongloden,项目名称:rumpel,代码行数:13,代码来源:images.service.ts

示例4: constructor5

 // forkJoin pattern    
 constructor5() {
     console.log(new Observable());
     
     var userStream = Observable.of({
         userId: 1, username: 'kling'
     }).delay(2000);
     
     var tweetStream = Observable.of([1,2,3]).delay(1500);
     
     var c = Observable.forkJoin(userStream, tweetStream)
         .map(joined => new Object({user: joined[0], tweet: joined[1]}));
     //c.subscribe(x => console.log(x));   
     c.subscribe(x => console.log(x));  
 }
开发者ID:kwanling,项目名称:ng2test,代码行数:15,代码来源:app3.component.ts

示例5: ngOnInit

 ngOnInit() {
     let request = new Request({
         method: RequestMethod.Get,
         url: `https://api.github.com/repos/${this.organization}/${this.repo}/readme`,
         headers: new Headers({'Accept': 'application/vnd.github.full.html'})
     });
     Observable.forkJoin(
         this.http.request(request).map(res => res.text()),
         this.http.get(`https://api.github.com/repos/${this.organization}/${this.repo}/commits?per_page=25`).map(res => res.json())
     ).subscribe(res => {
         this.markdown = res[0];
         this.commits = res[1];
     });
 }
开发者ID:MicahFulton,项目名称:GithubOrgSearch,代码行数:14,代码来源:repo.ts

示例6:

    return Observable.create(observer => {

      Observable.forkJoin(
        that.getEndangeredMamals(),
        that.getEndageredBirds()
      ).subscribe(data => {
        list = data[0];
        list.push.apply(list, data[1]);

        observer.next(list);
        observer.complete();

      });
    });
开发者ID:eventures-io,项目名称:ng2-rx,代码行数:14,代码来源:backend.service.ts

示例7: startUpload

 startUpload(sessionId: string, file: any) {
   Observable.forkJoin(
     this.configService.getFileBrokerUrl(),
     this.createDataset(sessionId, file.name)
   ).subscribe((value: [string, Dataset]) => {
     const url = value[0];
     const dataset = value[1];
     file.chipsterTarget = `${url}/sessions/${sessionId}/datasets/${
       dataset.datasetId
     }?token=${this.tokenService.getToken()}`;
     file.chipsterSessionId = sessionId;
     file.chipsterDatasetId = dataset.datasetId;
     file.resume();
   }, err => this.restErrorService.showError("upload failed", err));
 }
开发者ID:chipster,项目名称:chipster-web,代码行数:15,代码来源:upload.service.ts

示例8: uploadUser

 private uploadUser(user: firebase.User): Observable<[User, UserPrivate]> {
   const platformUser = new User({
     $key: user.uid,
     displayName: user.displayName,
     photoURL: user.photoURL,
     updatedAt: firebase.database.ServerValue.TIMESTAMP,
   });
   const platformUserPrivate = new UserPrivate({
     $key: user.uid,
     email: user.email,
   });
   return Observable.forkJoin(
     this.userService.updateUser(platformUser),
     this.userPrivateService.updateUserPrivate(platformUserPrivate),
   );
 }
开发者ID:blmsl,项目名称:memories,代码行数:16,代码来源:auth.service.ts

示例9: constructor6

 // catch observable error pattern    
 constructor6() {
     console.log(new Observable());
     
     var userStream = Observable.throw(new Error("Something failed"));
     
     var tweetStream = Observable.of([1,2,3]).delay(1500);
     
     var c = Observable.forkJoin(userStream, tweetStream)
         .map(joined => new Object({user: joined[0], tweet: joined[1]}));
         
     //c.subscribe(x => console.log(x));   
     c.subscribe(
         x => console.log(x),
         error => console.error(error)
         );  
 }
开发者ID:kwanling,项目名称:ng2test,代码行数:17,代码来源:app3.component.ts

示例10: getData

    getData() {
      const countryDetails$ = this.countryDetailsService.getData(this.country, this.lang);
      const weather$ = this.weatherService.getData(this.lat, this.lng);
      const images$ = this.imagesService.getData(this.name);
      const countrydescription$ = this.countryDescriptionService.getData(this.name, this.lang);

      Rx.Observable.forkJoin([countryDetails$, weather$, images$, countrydescription$]).subscribe(
        res => {
          this.countrydetails = res[0].geonames[0],
          this.weatherdetails = res[1].weatherObservation,
          this.images = res[2].hits.length == 3 ? res[2].hits : null,
          this.countrydescription = res[3].geonames
        },
        err => console.log(err)
      );
      // TODO handle error
    }
开发者ID:aroget,项目名称:ng2-countries,代码行数:17,代码来源:index.ts

示例11: ngOnInit

  ngOnInit() {
    console.clear();
    Observable.forkJoin(
      this.http.get('http://jsonplaceholder.typicode.com/todos').map(res => res.json()),
      this.http.get('https://jsonplaceholder.typicode.com/users').map(res => res.json())
    ).subscribe(
      data => console.log(data),
      err => console.error(err.message)
      );

    let p1 = this.http.get('http://jsonplaceholder.typicode.com/todos').map(res => res.json()).toPromise();
    let p2 = this.http.get('https://jsonplaceholder.typicode.com/users').map(res => res.json()).toPromise();

    Promise.all([p1, p2]).then(values => {
      console.log('Promise',values);
    })
  }
开发者ID:chgc,项目名称:presentation-rxjs,代码行数:17,代码来源:demo3.component.ts

示例12: Date

                    .subscribe(prContainer => {
                        // get first page of pull requests
                        let pullRequests = prContainer.values;

                        // Calc number of other pages to get
                        let nbPages = Math.ceil(prContainer.size / prContainer.pagelen);

                        if (nbPages === 1) {
                            // Return the result to the observers
                            observer.next(pullRequests);
                        }

                        // Build array of fetch to subscribe
                        let fetchPages: any[] = [];
                        for (let i = 2; i <= nbPages; i++) {
                            fetchPages.push(this.fetchPullRequestPage(i));
                        }

                        // get synchrone result of all fetch
                        Observable.forkJoin(fetchPages).subscribe(datas => {
                            let dataArray: any = datas;
                            dataArray.forEach((data: any) => {
                                pullRequests = pullRequests.concat(data.values);
                            });

                            let modelPullRequests: PullRequest[] = pullRequests.map((pullRequest: any) => {

                                let modelPullRequest: PullRequest = {
                                    id: pullRequest.id,
                                    title: pullRequest.title,
                                    description: pullRequest.description,
                                    merge_commit: pullRequest.merge_commit,
                                    author: {userName: pullRequest.username,
                                             displayName: pullRequest.display_name,
                                             uuid: pullRequest.uuid},
                                    createdOn: new Date(pullRequest.created_on),
                                    updatedOn: new Date(pullRequest.updated_on),
                                    commentCount: pullRequest.comment_count
                                };
                                return modelPullRequest;
                            });
                            observer.next(modelPullRequests);
                        });

                    }, err => {
开发者ID:vnctaing,项目名称:stethoscope,代码行数:45,代码来源:bitbucket.service.ts

示例13:

 this.dspaceService.createItem(this.item.sanitize(), token, currentContext.id).subscribe(response => {
     if(response.status == 200) {
         this.item.id = JSON.parse(response.text()).id;
         if(this.files.length > 0) {
             let bitStreamObservables = new Array<any>();
             for(let file of this.files) {
                 bitStreamObservables.push(this.dspaceService.addBitstream(this.item, file, token));
             }
             Observable.forkJoin(bitStreamObservables).subscribe(bitstreamResponses => {
                 this.finish(this.item.name, currentContext);
             },
             errors => {
                 this.finish(this.item.name, currentContext);
             });
         }
         else {
             this.finish(this.item.name, currentContext);
         }
     }
 },
开发者ID:hardyoyo,项目名称:angular2-ui-prototype,代码行数:20,代码来源:item-create.component.ts

示例14: getAlbum

 getAlbum(id) {
   return Observable.forkJoin(
     this.http.get(`api/albums/${id}`).map(res => res.json().album),
     this.http.get(`api/albums/${id}/tracks`).map(res => res.json().tracks)
   )
 }
开发者ID:creedarky,项目名称:angular2-music,代码行数:6,代码来源:albums-service.service.ts

示例15: getBooksAndMovies

 // Uses Observable.forkJoin() to run multiple concurrent http.get() requests.
 // The entire operation will result in an error state if any single request fails.
 getBooksAndMovies() {
   return Observable.forkJoin(
     this.http.get('/app/books.json').map((res:Response) => res.json()),
     this.http.get('/app/movies.json').map((res:Response) => res.json())
   );
 }
开发者ID:Alberto-Velez,项目名称:Mean_Stack-,代码行数:8,代码来源:demo.service.ts


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