The following ngrx select is deprecated.
this.store.select(state => state.academy.academy).subscribe((academy) => { this.academy = academy; });
I found this at store.d.ts
@deprecated from 6.1.0. Use the pipeable `select` operator instead.
So... what's the correct syntax?
I try
this.store.pipe(select(state => state.academy.academy).subscribe((academy) => { this.academy = academy; }))
Error: Cannot find name 'select'. Did you mean 'onselect'?
select() has been deprecated. However, notice for the same is added in release v6. 1.0. As Store<T> itself extends Observable<T> , it returns observable which can easily be subscribed using .
Store. select returns an observable that you can subscribe to either in your component or template via '|async'.
import {Component, OnInit} from '@angular/core'; import {Store, select} from '@ngrx/store'; import {AppState} from '../../../../../app.state'; @Component({ selector: 'app-layout', templateUrl: './layout.component.html', styleUrls: ['./layout.component.scss'] }) export class PageLayoutComponent implements OnInit { academy; constructor( private store: Store<AppState> ) { } ngOnInit() { this.store.pipe(select((state: any) => state.academy.academy)).subscribe((academy) => { this.academy = academy; }); } }
As per NgRx 7, the select
method is un-deprecated.
For more info, see the associated Pull Request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With