Reputation: 522
In this article on medium.com (13 Feb.) regarding NGRX 5 they present pipeable selectors. This reminds me on reading about pipeable selectors in rxjs where they could not just be justified by 'its pure function, bro', but also by the way functions could be declared and reused in different occurences without using map every time to then call a letable function.
So i can agree, that this is a good thing in rxjs, but why would we need this in ngrx - for selectors. The linked article shows the following example:
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
interface AppState {
count: number;
}
@Component({
selector: 'my-app',
template: `
<button (click)="increment()">Increment</button>
<div>Current Count: {{ count$ | async }}</div>
<button (click)="decrement()">Decrement</button>
<button (click)="reset()">Reset Counter</button>
`
})
export class MyAppComponent {
count$: Observable<number>;
constructor(private store: Store<AppState>) {
this.count$ = store.pipe(select('count'));
}
}
So we now call store.pipe(select(...));
instead of store.select(Selector);
- where are the gains? why should i change my code to use this behaviour or at least start to use pipeable selectors?
Upvotes: 8
Views: 1192
Reputation: 15525
In NgRx 7 this deprecation is been reverted - see changelog.
Upvotes: 1