store
store copied to clipboard
Store: Support for observable selectors e.g. let
This is a...
- [x] feature request
- [ ] bug report
- [ ] usage question
What toolchain are you using for transpilation/bundling?
- [ ] @angular/cli
- [x] Custom @ngTools/webpack
- [ ] Raw
ngc
- [ ] SystemJS
- [ ] Rollup
- [ ] Other
Environment
NodeJS Version: Typescript Version: Angular Version: @angular-redux/store version: @angular/cli version: (if applicable) OS:
Expected Behaviour:
Would be nice to have a feature which allows you to write selectors which can handle additional observable logic.
e.g.
isAuthenticated$() {
return (state$: Observable<SharedState>): Observable<boolean | undefined> =>
state$.map(x => x.auth.isAuthenticated)
.filter(x => x !== undefined);
}
// and used as following
store.select(this.selector.isAuthenticated$())
.do(...);
// or
store.let(this.selector.isAuthenticated$())
.do(...);
This was supported in ngrx and it was quite useful.
Actual Behaviour:
Currently, in order to make it work I need to use it as follows:
this.store.select(x => x)
.let(this.selector.isAuthenticated$())
Stack Trace/Error Message:
Additional Notes:
(optional)
Can't you use the @select$ decorator to do this?
I don't think you get what I want with that. What I want is to create a reusable selector and add additional filters etc.. on the observable. With the decorator you still wont have access to it as an observable but only as a function