feat(core): upgrade rxjs to 6.0.0-alpha.4 (#22573)

PR Close #22573
This commit is contained in:
Igor Minar
2018-02-27 17:06:06 -05:00
parent c445314239
commit b43f8bc7d3
270 changed files with 10104 additions and 1860 deletions

View File

@ -5,6 +5,7 @@
import { ExceptionService, SpinnerService, ToastService } from '../../core';
import { Http } from '@angular/http';
import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
import { Hero } from './hero.model';
// #enddocregion example
@ -19,13 +20,13 @@ export class HeroService {
) { }
getHero(id: number) {
return this.http.get(`api/heroes/${id}`)
.map(response => response.json().data as Hero);
return this.http.get(`api/heroes/${id}`).pipe(
map(response => response.json().data as Hero));
}
getHeroes() {
return this.http.get(`api/heroes`)
.map(response => response.json().data as Hero[]);
return this.http.get(`api/heroes`).pipe(
map(response => response.json().data as Hero[]));
}
}

View File

@ -2,6 +2,7 @@
// #docregion example
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { map } from 'rxjs/operators';
import { Hero } from './hero.model';
import { ExceptionService, SpinnerService, ToastService } from '../../core';
@ -19,13 +20,13 @@ export class HeroService {
) { }
getHero(id: number) {
return this.http.get(`api/heroes/${id}`)
.map(response => response.json() as Hero);
return this.http.get(`api/heroes/${id}`).pipe(
map(response => response.json() as Hero));
}
getHeroes() {
return this.http.get(`api/heroes`)
.map(response => response.json() as Hero[]);
return this.http.get(`api/heroes`).pipe(
map(response => response.json() as Hero[]));
}
}

View File

@ -1,6 +1,6 @@
// #docregion
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { Subscription } from 'rxjs';
import { LoggerService } from '../logger.service';
import { SpinnerState, SpinnerService } from './spinner.service';

View File

@ -1,6 +1,6 @@
// #docregion
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { Subject } from 'rxjs';
export interface SpinnerState {
show: boolean;

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { Hero, HeroService } from './shared';

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { Hero, HeroService } from './shared';

View File

@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Hero } from './hero.model';
@ -12,7 +12,8 @@ export class HeroService {
constructor(private http: Http) {}
getHeroes(): Observable<Hero[]> {
return this.http.get('api/heroes')
.map(resp => resp.json().data as Hero[]);
return this.http.get('api/heroes').pipe(
map(resp => resp.json().data as Hero[])
);
}
}

View File

@ -4,10 +4,8 @@
import { OnInit } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/finally';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs';
import { catchError, finalize, map } from 'rxjs/operators';
import { Hero } from '../shared/hero.model';
@ -18,11 +16,11 @@ export class HeroListComponent implements OnInit {
constructor(private http: Http) {}
getHeroes() {
this.heroes = [];
this.http.get(heroesUrl)
.map((response: Response) => <Hero[]>response.json().data)
.catch(this.catchBadResponse)
.finally(() => this.hideSpinner())
.subscribe((heroes: Hero[]) => this.heroes = heroes);
this.http.get(heroesUrl).pipe(
map((response: Response) => <Hero[]>response.json().data),
catchError(this.catchBadResponse),
finalize(() => this.hideSpinner())
).subscribe((heroes: Hero[]) => this.heroes = heroes);
}
ngOnInit() {
this.getHeroes();

View File

@ -1,8 +1,7 @@
// #docregion
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import { of } from 'rxjs';
import { Hero } from './hero.model';
@ -10,6 +9,6 @@ import { Hero } from './hero.model';
export class HeroService {
getHeroes() {
let heroes: Hero[] = [];
return Observable.of(heroes);
return of(heroes);
}
}

View File

@ -1,6 +1,7 @@
// #docregion
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { map } from 'rxjs/operators';
import { Hero } from './hero.model';
@ -10,8 +11,8 @@ export class HeroService {
constructor(private http: Http) { }
getHeroes() {
return this.http.get('api/heroes')
.map((response: Response) => <Hero[]>response.json());
return this.http.get('api/heroes').pipe(
map((response: Response) => <Hero[]>response.json()));
}
}
// #enddocregion example

View File

@ -1,8 +1,7 @@
// #docregion
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import { Observable, of } from 'rxjs';
import { Hero } from './hero.model';
@ -10,6 +9,6 @@ import { Hero } from './hero.model';
export class HeroService {
getHeroes() {
let heroes: Hero[] = [];
return Observable.of(heroes);
return of(heroes);
}
}

View File

@ -1,8 +1,7 @@
// #docregion
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import { of } from 'rxjs';
import { Hero } from './hero.model';
@ -10,6 +9,6 @@ import { Hero } from './hero.model';
export class HeroService {
getHeroes() {
let heroes: Hero[] = [];
return Observable.of(heroes);
return of(heroes);
}
}

View File

@ -1,6 +1,5 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import 'rxjs/add/operator/map';
platformBrowserDynamic().bootstrapModule(AppModule);