From 66c9987b6640ccf6c5ece7bbe8816cdba8ebf393 Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Sun, 20 Jan 2019 16:32:27 -0200 Subject: [PATCH] Remove entity constructor --- src/classes/EventEntity.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/classes/EventEntity.ts b/src/classes/EventEntity.ts index a1fb328..c9d6bc0 100644 --- a/src/classes/EventEntity.ts +++ b/src/classes/EventEntity.ts @@ -1,6 +1,5 @@ import { IEvent, Reducer, ICommitFunction } from '@nxcd/tardis' import { IEventEntity } from '../interfaces/IEventEntity' -import { IEntityConstructor } from '../interfaces/IEntityConstructor'; export abstract class EventEntity implements IEventEntity { [key: string]: any @@ -9,18 +8,9 @@ export abstract class EventEntity implements IEventEntity { id: any = null protected reducer: Reducer - protected _Entity?: IEntityConstructor - constructor (knownEvents: { [eventName: string]: ICommitFunction }, entity?: IEntityConstructor) { + constructor (knownEvents: { [eventName: string]: ICommitFunction }) { this.reducer = new Reducer(knownEvents) - - // TODO: Remove this on next major version - if (!entity) { - console.warn("[@nxcd/paradox] DEPRECATED: Calling EventEntity's constructor without passing the Entity constructor is deprecated and will stop being supported soon") - return - } - - this._Entity = entity } get state (): any { @@ -28,9 +18,7 @@ export abstract class EventEntity implements IEventEntity { } private updateState () { - const state = this._Entity - ? this.reducer.reduce(new this._Entity(), [ ...this.persistedEvents, ...this.pendingEvents ]) - : this.state + const state = this.state for (const propertyName of Object.keys(state)) { this[propertyName] = state[propertyName]