Skip to content

Commit

Permalink
refactor(Entity): Expose Update interface (#675)
Browse files Browse the repository at this point in the history
closes #670
  • Loading branch information
sandangel authored and brandonroberts committed Dec 29, 2017
1 parent 95dd2dc commit d9b37cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions docs/entity/adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export interface User {

```ts
import { Action } from '@ngrx/store';
import { Update } from '@ngrx/entity';

import { User } from './user.model';

export const LOAD_USERS = '[User] Load Users';
Expand Down Expand Up @@ -134,13 +136,13 @@ export class AddUsers implements Action {
export class UpdateUser implements Action {
readonly type = UPDATE_USER;

constructor(public payload: { user: { id: string, changes: User } }) {}
constructor(public payload: { user: Update<User> }) {}
}

export class UpdateUsers implements Action {
readonly type = UPDATE_USERS;

constructor(public payload: { users: { id: string, changes: User }[] }) {}
constructor(public payload: { users: Update<User>[] }) {}
}

export class DeleteUser implements Action {
Expand Down
2 changes: 1 addition & 1 deletion modules/entity/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { createEntityAdapter } from './create_adapter';
export { EntityState, EntityAdapter } from './models';
export { EntityState, EntityAdapter, Update } from './models';
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Action } from '@ngrx/store';
import { Update } from '@ngrx/entity';
import { <%= classify(name) %> } from './<%= dasherize(name) %>.model';

export enum <%= classify(name) %>ActionTypes {
Expand Down Expand Up @@ -33,13 +34,13 @@ export class Add<%= classify(name) %>s implements Action {
export class Update<%= classify(name) %> implements Action {
readonly type = <%= classify(name) %>ActionTypes.Update<%= classify(name) %>;

constructor(public payload: { <%= lowercase(name) %>: { id: string, changes: <%= classify(name) %> } }) {}
constructor(public payload: { <%= lowercase(name) %>: Update<<%= classify(name) %>> }) {}
}

export class Update<%= classify(name) %>s implements Action {
readonly type = <%= classify(name) %>ActionTypes.Update<%= classify(name) %>s;

constructor(public payload: { <%= lowercase(name) %>s: { id: string, changes: <%= classify(name) %> }[] }) {}
constructor(public payload: { <%= lowercase(name) %>s: Update<<%= classify(name) %>>[] }) {}
}

export class Delete<%= classify(name) %> implements Action {
Expand Down

0 comments on commit d9b37cd

Please sign in to comment.