File tree Expand file tree Collapse file tree 6 files changed +41
-1
lines changed
HarryPotter/src/app/components Expand file tree Collapse file tree 6 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { AppService } from 'src/app/app.service' ;
3
3
import { IBookType } from 'src/app/models' ;
4
+ import { takeUntil } from 'rxjs/operators' ;
5
+ import { Subject } from 'rxjs' ;
4
6
5
7
@Component ( {
6
8
selector : 'app-books' ,
@@ -9,8 +11,12 @@ import { IBookType } from 'src/app/models';
9
11
} )
10
12
export class BooksComponent implements OnInit {
11
13
books :Array < IBookType > = [ ] ;
14
+ unSubscribeAll = new Subject < any > ( ) ;
12
15
constructor ( private appService :AppService ) {
13
16
this . appService . getBooks ( )
17
+ . pipe (
18
+ takeUntil ( this . unSubscribeAll )
19
+ )
14
20
. subscribe ( data => {
15
21
this . books = data ;
16
22
} ) ;
Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { AppService } from 'src/app/app.service' ;
3
3
import { IPersonType } from 'src/app/models/personItem.model' ;
4
+ import { takeUntil } from 'rxjs/operators' ;
5
+ import { Subject } from 'rxjs' ;
4
6
5
7
@Component ( {
6
8
selector : 'app-characters' ,
@@ -9,8 +11,12 @@ import { IPersonType } from 'src/app/models/personItem.model';
9
11
} )
10
12
export class CharactersComponent implements OnInit {
11
13
characters :Array < IPersonType > = [ ] ;
14
+ unSubscribeAll = new Subject < any > ( ) ;
12
15
constructor ( private appService :AppService ) {
13
16
this . appService . getCharacters ( )
17
+ . pipe (
18
+ takeUntil ( this . unSubscribeAll )
19
+ )
14
20
. subscribe ( data => {
15
21
this . characters = data ;
16
22
} ) ;
Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { AppService } from 'src/app/app.service' ;
3
3
import { IFilmType } from 'src/app/models' ;
4
+ import { takeUntil } from 'rxjs/operators' ;
5
+ import { Subject } from 'rxjs' ;
4
6
5
7
@Component ( {
6
8
selector : 'app-films' ,
@@ -9,8 +11,13 @@ import { IFilmType } from 'src/app/models';
9
11
} )
10
12
export class FilmsComponent implements OnInit {
11
13
films : Array < IFilmType > = [ ] ;
14
+ unSubscribeAll = new Subject < any > ( ) ;
12
15
constructor ( private appService : AppService ) {
13
- this . appService . getFilms ( ) . subscribe ( ( data ) => ( this . films = data ) ) ;
16
+ this . appService . getFilms ( )
17
+ . pipe (
18
+ takeUntil ( this . unSubscribeAll )
19
+ )
20
+ . subscribe ( ( data ) => ( this . films = data ) ) ;
14
21
}
15
22
16
23
ngOnInit ( ) : void { }
Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { AppService } from 'src/app/app.service' ;
3
3
import { IHouseType } from 'src/app/models' ;
4
+ import { takeUntil } from 'rxjs/operators' ;
5
+ import { Subject } from 'rxjs' ;
4
6
5
7
@Component ( {
6
8
selector : 'app-houses' ,
@@ -9,8 +11,13 @@ import { IHouseType } from 'src/app/models';
9
11
} )
10
12
export class HousesComponent implements OnInit {
11
13
houses :Array < IHouseType > = [ ] ;
14
+ unSubscribeAll = new Subject < any > ( ) ;
15
+
12
16
constructor ( private appService :AppService ) {
13
17
this . appService . getHouses ( )
18
+ . pipe (
19
+ takeUntil ( this . unSubscribeAll )
20
+ )
14
21
. subscribe ( data => {
15
22
this . houses = data ;
16
23
} ) ;
Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { AppService } from 'src/app/app.service' ;
3
3
import { IPersonType } from 'src/app/models/personItem.model' ;
4
+ import { takeUntil } from 'rxjs/operators' ;
5
+ import { Subject } from 'rxjs' ;
4
6
5
7
@Component ( {
6
8
selector : 'app-staff' ,
@@ -9,8 +11,13 @@ import { IPersonType } from 'src/app/models/personItem.model';
9
11
} )
10
12
export class StaffComponent implements OnInit {
11
13
staff :Array < IPersonType > = [ ] ;
14
+ unSubscribeAll = new Subject < any > ( ) ;
15
+
12
16
constructor ( private appService :AppService ) {
13
17
this . appService . getStaff ( )
18
+ . pipe (
19
+ takeUntil ( this . unSubscribeAll )
20
+ )
14
21
. subscribe ( data => {
15
22
this . staff = data ;
16
23
} ) ;
Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { AppService } from 'src/app/app.service' ;
3
3
import { IPersonType } from 'src/app/models/personItem.model' ;
4
+ import { takeUntil } from 'rxjs/operators' ;
5
+ import { Subject } from 'rxjs' ;
4
6
5
7
@Component ( {
6
8
selector : 'app-students' ,
@@ -9,8 +11,13 @@ import { IPersonType } from 'src/app/models/personItem.model';
9
11
} )
10
12
export class StudentsComponent implements OnInit {
11
13
students :Array < IPersonType > = [ ] ;
14
+ unSubscribeAll = new Subject < any > ( ) ;
15
+
12
16
constructor ( private appService :AppService ) {
13
17
this . appService . getStudents ( )
18
+ . pipe (
19
+ takeUntil ( this . unSubscribeAll )
20
+ )
14
21
. subscribe ( data => {
15
22
this . students = data ;
16
23
} ) ;
You can’t perform that action at this time.
0 commit comments