Reputation: 1155
Consider the following code
user$ = this._store.pipe(select(UserSelectors.selectUser));
Now we have an Observable that can be used like this:
(user$ | async)?.name
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.
Upvotes: 0
Views: 1553
Reputation: 220
NgRx ist a Redux implementation, which is designed for reactive programming.
Reactive:
Your way ist not reactive, thats why it does not work with NgRx. You can do it without a store or you must find a reactive way to solve your problem.
Upvotes: 1
Reputation: 15505
This isn't possible. I would even say that this is an anti-pattern.
Upvotes: 1