UNPKG

@ones-open/node-host

Version:
33 lines (32 loc) 903 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.onEvent = void 0; const plugin_1 = require("../plugin"); const logger_1 = require("../logger"); // OnEvent 的实现 const onEvent = () => { setInterval(runOnEventAll, 3000); }; exports.onEvent = onEvent; async function runOnEventAll() { runOnEvent(plugin_1.pluginManager.getPlugin()); } async function runOnEvent(plugin) { try { const subId = 'mock subId'; const eventType = 'timestamp'; const payload = { interval: { type: 'ms', value: 3, }, timestamp: +new Date(), }; await plugin.runMethod('OnEvent', subId, eventType, payload); } catch (err) { if (!plugin.isMethodNotFoundError(err)) { logger_1.logger.error(`OnEvent hook execute failed: `, err); } } }