Skip to content

Commit 8c5cac0

Browse files
committed
42. Create spinner side effect for loadproduct
1 parent 52d5c6c commit 8c5cac0

File tree

3 files changed

+7
-37
lines changed

3 files changed

+7
-37
lines changed

src/app/modules/products/product-item/product-item.component.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ export class ProductItemComponent implements OnInit {
5252
);
5353
})
5454
);
55-
// this.spinner.show();
56-
57-
// this.product$ = this.service.getProduct(
58-
// this.route.snapshot.paramMap.get('id')
59-
// );
60-
61-
// setTimeout(() => {
62-
// this.spinner.hide();
63-
// }, 1000);
6455
}
6556

6657
deleteProduct(id: number) {
Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import { ActivatedRoute } from '@angular/router';
3-
import { MockProductApiService } from '../resources/mock-product-api.service';
43
import { Product } from '../resources/product';
5-
import { NgxSpinnerService } from 'ngx-spinner';
6-
import { AlertService } from 'ngx-alerts';
74
import * as fromProductSelectors from '../state/product.selectors';
85
import { Store, select } from '@ngrx/store';
96
import { AppState } from 'src/app/store';
@@ -21,12 +18,7 @@ export class ProductViewComponent implements OnInit {
2118
isProductInStore$: Observable<boolean>;
2219
product$: Observable<Product>;
2320

24-
constructor(
25-
private route: ActivatedRoute,
26-
private productService: MockProductApiService,
27-
private spinner: NgxSpinnerService,
28-
private store: Store<AppState>
29-
) {}
21+
constructor(private route: ActivatedRoute, private store: Store<AppState>) {}
3022

3123
ngOnInit(): void {
3224
this.productId = this.route.snapshot.paramMap.get('id');
@@ -50,22 +42,5 @@ export class ProductViewComponent implements OnInit {
5042
);
5143
})
5244
);
53-
54-
// this.spinner.show();
55-
// const observer = {
56-
// next: (product) => {
57-
// this.product = product;
58-
// setTimeout(() => {
59-
// this.spinner.hide();
60-
// }, 1000);
61-
// },
62-
// error: (err) => {
63-
// this.spinner.hide();
64-
// console.error(err);
65-
// },
66-
// };
67-
// this.productService
68-
// .getProduct(this.route.snapshot.paramMap.get('id'))
69-
// .subscribe(observer);
7045
}
7146
}

src/app/store/effects/spinner.effects.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export class SpinnerEffects {
1515
fromAuthActions.loginPage,
1616
fromAuthActions.loginModal,
1717
fromProductActions.loadProducts,
18-
fromProductActions.loadAdminProducts
18+
fromProductActions.loadAdminProducts,
19+
fromProductActions.loadProduct,
20+
fromProductActions.loadAdminProduct
1921
),
2022
tap(() => this.spinner.show())
2123
),
@@ -29,7 +31,9 @@ export class SpinnerEffects {
2931
fromAuthActions.loginSuccess,
3032
fromAuthActions.loginFailure,
3133
fromProductActions.loadProductsFailure,
32-
fromProductActions.loadProductsSuccess
34+
fromProductActions.loadProductsSuccess,
35+
fromProductActions.loadProductFailure,
36+
fromProductActions.loadProductSuccess
3337
),
3438
tap(() => {
3539
setTimeout(() => {

0 commit comments

Comments
 (0)