Open spierala opened 7 months ago
@spierala I can pick this up if you want but is the idea to remove createFeatureSelector
completely in the next release? Or do you want to fix this but keep createFeatureSelector
available?
You can pick this up for sure!
I would like to keep createFeatureSelector, maybe never remove it. Because NgRx has a createFeatureSelector. It makes refactor from NgRx to MiniRx slightly more easy :)
@spierala in this case it's probably just easiest to duplicate the implementation? In my opinion, that makes it more clear which overloads are available for createFeatureStateSelector
and what exactly is deprecated. The disadvantage obviously being that you'd have to make changes twice when the implementation changes.
/** @deprecated Use `createFeatureStateSelector` which is more in line with `createComponentStateSelector` */
export function createFeatureSelector<T>(featureKey?: string): Selector<object, T>;
/** @deprecated Use `createFeatureStateSelector` which is more in line with `createComponentStateSelector` */
export function createFeatureSelector<T, V>(featureKey: keyof T): Selector<T, V>;
/** @deprecated Use `createFeatureStateSelector` which is more in line with `createComponentStateSelector` */
export function createFeatureSelector(featureKey?: any): Selector<any, any> {
if (featureKey) {
return createSelector(
(state: any) => state[featureKey],
(featureState) => featureState
);
}
return (state) => state;
}
export function createFeatureStateSelector<T>(featureKey?: string): Selector<object, T>;
export function createFeatureStateSelector<T, V>(featureKey: keyof T): Selector<T, V>;
export function createFeatureStateSelector(featureKey?: any): Selector<any, any> {
if (featureKey) {
return createSelector(
(state: any) => state[featureKey],
(featureState) => featureState
);
}
return (state) => state; // Do not memoize: when used with FeatureStore there is a new state object created for every `setState`
}
In IntelliJ there is a wrong deprecation warning for
createFeatureStateSelector
.This function is not deprecated. Only
createFeatureSelector
is deprecated.I guess that the confusion comes from this typing: