From d9b37cdf49327834740fb586d0da4936ef1e3563 Mon Sep 17 00:00:00 2001 From: Nguyen San Date: Fri, 29 Dec 2017 22:44:02 +0900 Subject: [PATCH] refactor(Entity): Expose Update interface (#675) closes #670 --- docs/entity/adapter.md | 6 ++++-- modules/entity/src/index.ts | 2 +- .../src/entity/files/__path__/__name@dasherize__.actions.ts | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/entity/adapter.md b/docs/entity/adapter.md index c7bff992dc..7219cc492d 100644 --- a/docs/entity/adapter.md +++ b/docs/entity/adapter.md @@ -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'; @@ -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 }) {} } export class UpdateUsers implements Action { readonly type = UPDATE_USERS; - constructor(public payload: { users: { id: string, changes: User }[] }) {} + constructor(public payload: { users: Update[] }) {} } export class DeleteUser implements Action { diff --git a/modules/entity/src/index.ts b/modules/entity/src/index.ts index 2635a4dbbc..8f4475b88f 100644 --- a/modules/entity/src/index.ts +++ b/modules/entity/src/index.ts @@ -1,2 +1,2 @@ export { createEntityAdapter } from './create_adapter'; -export { EntityState, EntityAdapter } from './models'; +export { EntityState, EntityAdapter, Update } from './models'; diff --git a/modules/schematics/src/entity/files/__path__/__name@dasherize__.actions.ts b/modules/schematics/src/entity/files/__path__/__name@dasherize__.actions.ts index 5b79b7c2bb..02e55dc74b 100644 --- a/modules/schematics/src/entity/files/__path__/__name@dasherize__.actions.ts +++ b/modules/schematics/src/entity/files/__path__/__name@dasherize__.actions.ts @@ -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 { @@ -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 {