Skip to content

Commit

Permalink
feat(Entity): Add default selectId function for EntityAdapter (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipzada authored and brandonroberts committed Sep 20, 2017
1 parent 193e8b3 commit 2afb792
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions modules/entity/src/create_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +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> {
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
8 changes: 6 additions & 2 deletions modules/store/src/store_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,16 @@ export class StoreModule {
): ModuleWithProviders;
static forFeature<T, V extends Action = Action>(
featureName: string,
reducer: ActionReducer<T, V>| InjectionToken<ActionReducer<T, V>>,
reducer: ActionReducer<T, V> | InjectionToken<ActionReducer<T, V>>,
config?: StoreConfig<T, V>
): ModuleWithProviders;
static forFeature(
featureName: string,
reducers: ActionReducerMap<any, any> | InjectionToken<ActionReducerMap<any, any>> | ActionReducer<any, any> | InjectionToken<ActionReducer<any, any>>,
reducers:
| ActionReducerMap<any, any>
| InjectionToken<ActionReducerMap<any, any>>
| ActionReducer<any, any>
| InjectionToken<ActionReducer<any, any>>,
config: StoreConfig<any, any> = {}
): ModuleWithProviders {
return {
Expand Down

0 comments on commit 2afb792

Please sign in to comment.