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?
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.