Consider the following code
user$ = this._store.pipe(select(UserSelectors.selectUser));
Now we have an Observable that can be used like this:
- In View :
(user$ | async)?.name
- In Component (TS) :
let storeValue: IUser;
this.user$.pipe(take(1)).subscribe(value => storeValue = value);
So in my Component I implemented a getter:
protected get user(): IUser {
let storeValue: IUser;
this.user$.pipe(take(1)).subscribe(value => storeValue = value);
return storeValue;
}
I am wondering if there is a way to use the selector to return the actual value, something like:
user = this._store.VALUE(select(UserSelectors.selectUser));
So all my getter logic is taken care of.
This isn't possible. I would even say that this is an anti-pattern.