import onfire from 'onfire'; export default class DataModelBase { constructor(modelName) { this._name = modelName; this._guid = onfire.getGuid(); this._slice = Function.call.bind(Array.prototype.slice); } getModelName() { return this._name; } getAttributeEventID(attributeName) { return this._guid + attributeName; } on(attributeName,handler,context) { return onfire.on(this.getAttributeEventID(attributeName) ,handler,context); } off(event) { var type = typeof event; if (type === 'string') { onfire.un(this.getAttributeEventID(event)); } else if (type === 'object' || type === 'function') { onfire.un(event); } } onReset() { } reset() { onfire.fireSync('reset',this); this.onReset(); } onDestoy() { } destroy() { onfire.fireSync('destroy',this); this.onDestoy(); } setData(msgId,pb) { } emit(attributeName) { onfire.fireSync(this.getAttributeEventID(attributeName),this,this._slice(arguments,1)); } }