diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index c206c263..bc7ef509 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -2,6 +2,15 @@ +# 6.0.2-beta.8 (2018-06-27) + +Minor internal refactoring + +* `EntityActionFactory` - Polymorphic `create` method delegates to mono-morphic `createCore` method + which makes the factory easier to sub-class. + + + # 6.0.2-beta.7 (2018-06-26) This **major release** is primarily about the new, _change tracking_ feature, @@ -523,6 +532,17 @@ Developers can petition to re-expose them if they can offer good reasons. This change, described earlier, affects those developers who worked directly with `EntityAction` instances. +#### `EntityActionFactory.create` signature changed. + +The relocation of `EntityAction` properties to the payload forced changes to the `EntityActionFactory`, +most significantly its `create` signatures. + +The `create` method no longer accepts a source action. +Use `createFromAction` instead. + +This is a breaking change for anyone sub-classing `EntityActionFactory` or calling it directly with +one of its lesser used `create` signatures. + #### `EntityAction.op` property renamed `entityOp` While moving entity action properties to `EntityAction.payload`, the `op` property was renamed `entityOp` for three reasons. diff --git a/lib/package.json b/lib/package.json index 310c6299..d43d5f62 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "ngrx-data", - "version": "6.0.2-beta.7", + "version": "6.0.2-beta.8", "repository": "https://github.com/johnpapa/angular-ngrx-data.git", "license": "MIT", "peerDependencies": { diff --git a/lib/src/actions/entity-action-factory.ts b/lib/src/actions/entity-action-factory.ts index 3f6a9beb..e2247bcd 100644 --- a/lib/src/actions/entity-action-factory.ts +++ b/lib/src/actions/entity-action-factory.ts @@ -22,6 +22,7 @@ export class EntityActionFactory { */ create

(payload: EntityActionPayload

): EntityAction

; + // polymorphic create for the two signatures create

( nameOrPayload: EntityActionPayload

| string, entityOp?: EntityOp, @@ -30,16 +31,23 @@ export class EntityActionFactory { ): EntityAction

{ const payload: EntityActionPayload

= typeof nameOrPayload === 'string' ? { ...(options || {}), entityName: nameOrPayload, entityOp, data } : nameOrPayload; + return this.createCore(payload); + } - const { entityName, entityOp: op, tag } = payload; - + /** + * Create an EntityAction to perform an operation (op) for a particular entity type + * (entityName) with optional data and other optional flags + * @param payload Defines the EntityAction and its options + */ + protected createCore

(payload: EntityActionPayload

) { + const { entityName, entityOp, tag } = payload; if (!entityName) { throw new Error('Missing entity name for new action'); } - if (op == null) { + if (entityOp == null) { throw new Error('Missing EntityOp for new action'); } - const type = this.formatActionType(op, tag || entityName); + const type = this.formatActionType(entityOp, tag || entityName); return { type, payload }; }