UNPKG

wechaty-puppet

Version:

Abstract Puppet for Wechaty

40 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readyMixin = void 0; const state_switch_1 = require("state-switch"); const config_js_1 = require("../config.js"); const readyMixin = (mixinBase) => { class ReadyMixin extends mixinBase { readyIndicator; constructor(...args) { super(...args); config_js_1.log.verbose('ReadyMixin', 'constructor()'); this.readyIndicator = new state_switch_1.BooleanIndicator(); } async start() { config_js_1.log.verbose('ReadyMixin', 'start()'); await super.start(); this.on('ready', () => { this.readyIndicator.value(true); }); this.on('logout', () => { this.readyIndicator.value(false); }); this.on('reset', () => { this.readyIndicator.value(false); }); } async stop() { config_js_1.log.verbose('ReadyMixin', 'stop()'); this.readyIndicator.value(false); /** * Huan(202201) NOTE: super.stop() should be the last line of this method * becasue we should keep the reverse order of logic in start() */ await super.stop(); } } return ReadyMixin; }; exports.readyMixin = readyMixin; //# sourceMappingURL=ready-mixin.js.map