Skip to content

Commit

Permalink
fix(Store): Remove auto-memoization of selector functions
Browse files Browse the repository at this point in the history
This fixes situations where `Store.select()` would memoize a Reselect selector twice.

Closes #118
  • Loading branch information
karptonite authored and MikeRyanDev committed Jul 19, 2017
1 parent bfdb83b commit 90899f7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
6 changes: 0 additions & 6 deletions modules/store/src/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,3 @@ export function createFeatureSelector<T>(

return Object.assign(memoized, { release: reset });
}

export function isSelector(v: any): v is MemoizedSelector<any, any> {
return (
typeof v === 'function' && v.release && typeof v.release === 'function'
);
}
5 changes: 1 addition & 4 deletions modules/store/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Action, ActionReducer } from './models';
import { ActionsSubject } from './actions_subject';
import { StateObservable } from './state';
import { ReducerManager } from './reducer_manager';
import { isSelector, createSelector } from './selector';

@Injectable()
export class Store<T> extends Observable<T> implements Observer<Action> {
Expand Down Expand Up @@ -70,10 +69,8 @@ export class Store<T> extends Observable<T> implements Observer<Action> {

if (typeof pathOrMapFn === 'string') {
mapped$ = pluck.call(this, pathOrMapFn, ...paths);
} else if (typeof pathOrMapFn === 'function' && isSelector(pathOrMapFn)) {
mapped$ = map.call(this, pathOrMapFn);
} else if (typeof pathOrMapFn === 'function') {
mapped$ = map.call(this, createSelector(s => s, pathOrMapFn));
mapped$ = map.call(this, pathOrMapFn);
} else {
throw new TypeError(
`Unexpected type '${typeof pathOrMapFn}' in select operator,` +
Expand Down

0 comments on commit 90899f7

Please sign in to comment.