我想提供一个可以获取ngrx选择器的服务。好的做法是直接在select中使用createSelector吗?
@Injectable()
export class LoginSelector{
get data$() {
return this.store.pipe(
select(<b>createSelector</b>(
this.loginState,
function (state) {
return state && state.data;
}
))
);
}
constructor(
protected storeActions$: Actions,
protected store: Store<StoreState>,
) {}
}
可能不是因为createSelector总是重新运行新的MemoizedSelector
const selectData = <b>createSelector</b>(
this.loginState,
function (state) {
return state && state.data;
}
);
@Injectable()
export class LoginSelector{
get data$() {
return this.store.pipe(
select(selectData)
);
}
constructor(
protected storeActions$: Actions,
protected store: Store<StoreState>,
) {}
}
谢谢。