Skip to content

Commit af12972

Browse files
committed
- fix
1 parent a8f401e commit af12972

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

libs/products-mobile/src/lib/containers/products-mobile/products-mobile.component.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="products-container">
1+
<div class="products-container" *rxLet="state$; let state">
22
<pedro-products-filter
33
[categories]="categories"
44
[sortOptions]="sortOptions"
@@ -18,9 +18,9 @@
1818
<mat-card-content>
1919
<img [src]="product.imgUrl" />
2020
</mat-card-content>
21-
<mat-card-footer fxLayout="row" fxLayoutAlign="end center"
22-
>{{ product.price }}</mat-card-footer
23-
>
21+
<mat-card-footer fxLayout="row" fxLayoutAlign="end center">{{
22+
product.price
23+
}}</mat-card-footer>
2424
</mat-card>
2525
</div>
2626

libs/products/src/lib/containers/products/products.container.ts

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectorRef, Directive, OnDestroy } from '@angular/core';
1+
import { Directive, OnDestroy } from '@angular/core';
22
import { Sort } from '@angular/material/sort';
33
import { select, Store } from '@ngrx/store';
44
import {
@@ -7,8 +7,8 @@ import {
77
ProductsPartialState,
88
} from '@pedro/core';
99
import { Category, Pagination } from '@pedro/data';
10-
import { observableReducer, stateChanges } from '@pedro/utilities';
11-
import { merge, Subject, Subscription } from 'rxjs';
10+
import { observableReducer } from '@pedro/utilities';
11+
import { merge, Observable, Subject, Subscription } from 'rxjs';
1212
import {
1313
debounceTime,
1414
distinctUntilChanged,
@@ -30,7 +30,7 @@ import {
3030

3131
@Directive()
3232
export class Products implements OnDestroy {
33-
state: ProductsComponentState;
33+
readonly state$: Observable<ProductsComponentState>;
3434

3535
readonly setState = new Subject<Partial<ProductsComponentState>>();
3636

@@ -50,10 +50,7 @@ export class Products implements OnDestroy {
5050

5151
protected readonly subscriptions = new Subscription();
5252

53-
constructor(
54-
private readonly store: Store<ProductsPartialState>,
55-
private readonly changeDetectorRef: ChangeDetectorRef
56-
) {
53+
constructor(private readonly store: Store<ProductsPartialState>) {
5754
const categorySlice$ = this.category$.pipe(
5855
map((category) => ({ category }))
5956
);
@@ -98,21 +95,14 @@ export class Products implements OnDestroy {
9895

9996
const storeSlice$ = this.store.pipe(select(selectProductComponentState));
10097

101-
const state$ = stateChanges(
98+
this.state$ = observableReducer(
10299
PRODUCTS_COMPONENT_INITIAL_STATE,
103100
storeSlice$,
104101
resetPage$,
105102
changePage$,
106103
this.setState
107-
).pipe(
108-
tap((state) => {
109-
this.state = state;
110-
this.changeDetectorRef.detectChanges();
111-
})
112104
);
113105

114-
this.subscriptions.add(state$.subscribe());
115-
116106
this.subscriptions.add(effects$.subscribe());
117107
}
118108

0 commit comments

Comments
 (0)