/** * hbs预编译回调事件 * @author: chenfeng<feng.chen@yoho.cn> * @date: 2017/08/14 */ const EventEmitter = require('events'); const event = new EventEmitter(); let hbsEvent = { cbTick: 0, cbComTick: 0, event }; Object.defineProperty(hbsEvent, 'cb', { get() { hbsEvent.cbTick++; return this._cb; }, set(val) { this._cb = val; } }); hbsEvent.cb = () => { hbsEvent.cbComTick++; if (hbsEvent.cbTick <= hbsEvent.cbComTick) { event.emit('hbs-complete'); } }; module.exports = hbsEvent;