Skip to content

Commit

Permalink
#405 selectId as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipzada committed Sep 19, 2017
1 parent 3219623 commit 5249ac5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/entity/src/create_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import { createSelectorsFactory } from './state_selectors';
import { createSortedStateAdapter } from './sorted_state_adapter';
import { createUnsortedStateAdapter } from './unsorted_state_adapter';

export function createEntityAdapter<T>(options?: {
selectId: IdSelector<T>;
sortComparer?: false | Comparer<T>;
}): EntityAdapter<T> {
options = options || { selectId: (instance: any) => instance.id };

export function createEntityAdapter<T>(
options: {
selectId?: IdSelector<T>;
sortComparer?: false | Comparer<T>;
} = {}
): EntityAdapter<T> {
const { selectId, sortComparer }: EntityDefinition<T> = {
sortComparer: false,
selectId: (instance: any) => instance.id,
...options,
};

Expand Down

0 comments on commit 5249ac5

Please sign in to comment.