Reputation: 10140
I'm wondering whether the following two blocks of code behave in the same manner:
With pipe (from original ngrx sample):
pending$ = this.store.pipe(select(fromAuth.selectLoginPagePending));
error$ = this.store.pipe(select(fromAuth.selectLoginPageError));
And without one:
pending$ = this.store.select(fromAuth.selectLoginPagePending);
error$ = this.store.select(fromAuth.selectLoginPageError);
I've tested both and haven't noticed any apparent difference.
Thoughts?
Upvotes: 1
Views: 3807
Reputation: 42526
Yes, you are right. Both
pending$ = this.store.pipe(select(fromAuth.selectLoginPagePending));
error$ = this.store.pipe(select(fromAuth.selectLoginPageError));
and
pending$ = this.store.select(fromAuth.selectLoginPagePending);
error$ = this.store.select(fromAuth.selectLoginPageError);
carry out the same function, which is to obtain a slice of the store state , as described on the NgRX documentation on selectors.
However, the pipe()
utility allows you to chain the selector with RxJS pipeable operators, such as scan()
, and filter()
, allowing you to carry out other operations such as state transitions.
Upvotes: 1
Reputation: 15505
They both do the same thing.
Internally, the store.select
function calls the select
operator.
Upvotes: 1