My usual method of fetching data from the ngrx store used to be:
public getUser(): Observable<IUser> {
return this.store.select(store => store.users.selectedUser);
}
However, I am now attempting to transition to using createSelecor (ngrx 15) and have tried the following:
public getUser(): Observable<IUser> {
const user = createSelector((state: IAppState) => state.users,
(userState) => {
return userState;
}
);
return user;
}
This new approach is resulting in an error:
TS2740: Type 'MemoizedSelector<IAppState, IUserState, (s1: IUserState) => IUserState>' is missing the following properties from type 'Observable<IUser>': source, operator, lift, subscribe, and 3 more.
So my question is, how can I obtain an Observable from createSelecor
in order to perform the following:
this.storeSelector.getUser().subscribe((a) => {
console.log(a);
});
TypeScript is indicating a problem with the return type as Observable<IUser>
.
Thank you.