Skip to content

Commit 2c1f027

Browse files
committed
2.13 Loading Service Reactive Design
1 parent ff09c05 commit 2c1f027

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/app/loading.service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import { Injectable } from "@angular/core";
2+
import { Observable } from "rxjs";
23

34
@Injectable() //not provided in root
45
export class LoadingService {
56

7+
loading$ : Observable<boolean>;
8+
9+
showLoaderUntilCompleted<T>(obs$ : Observable<T>) : Observable<T>{
10+
return undefined
11+
}
12+
13+
loadingOn(){
14+
15+
}
16+
17+
loadingOff(){
18+
19+
}
20+
621
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
<div class="spinner-container">
2+
<div class="spinner-container" *ngIf="loadingService.loading$ | async">
33
<mat-spinner></mat-spinner>
44
</div>

src/app/loading/loading.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { LoadingService } from '../loading.service';
1010
export class LoadingComponent implements OnInit {
1111

1212

13-
constructor(private loadingService: LoadingService) {
13+
constructor(public loadingService: LoadingService) {
1414

1515
}
1616

0 commit comments

Comments
 (0)