| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- 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));
- }
- }
|