base.model.js 537 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * 模型基类。
  3. *
  4. * 模型基于异步模型,提供事件抽象。
  5. *
  6. * author: Sand
  7. * since: 2016.11.20
  8. */
  9. "use strict";
  10. let EventEmitter = require('events').EventEmitter;
  11. let RedisModel = require('./redis.model.js');
  12. class BaseModel extends RedisModel{
  13. constructor() {
  14. super();
  15. this._eventEmitter = new EventEmitter();
  16. }
  17. get eventEmitter(){
  18. return this._eventEmitter;
  19. }
  20. on(event, handler){
  21. this._eventEmitter.on(event, handler);
  22. }
  23. }
  24. module.exports = BaseModel;