|
@@ -1,7 +1,8 @@
|
|
1
|
+import { Observable } from 'rxjs';
|
1
|
2
|
import { MsgState } from './../../../ngrx/msg.state';
|
2
|
3
|
import { CompanyState } from './../../../ngrx/companies/company.state';
|
3
|
4
|
import { Component, OnInit } from '@angular/core';
|
4
|
|
-import { Store } from '@ngrx/store';
|
|
5
|
+import { select, Store } from '@ngrx/store';
|
5
|
6
|
|
6
|
7
|
@Component({
|
7
|
8
|
selector: 'app-companies-management',
|
|
@@ -12,14 +13,14 @@ export class CompaniesManagementComponent implements OnInit {
|
12
|
13
|
|
13
|
14
|
constructor(private store: Store<{companyReducerKey: CompanyState}>) { }
|
14
|
15
|
|
15
|
|
- companyState!: CompanyState;
|
|
16
|
+ companyState$!: Observable<CompanyState>;
|
16
|
17
|
msgState = MsgState;
|
17
|
18
|
|
18
|
19
|
ngOnInit(): void {
|
19
|
20
|
|
20
|
|
- this.store.subscribe( state =>{
|
21
|
|
- this.companyState = state.companyReducerKey;
|
22
|
|
- })
|
|
21
|
+ this.companyState$ = this.store.pipe(
|
|
22
|
+ select( state => state.companyReducerKey)
|
|
23
|
+ );
|
23
|
24
|
}
|
24
|
25
|
|
25
|
26
|
}
|