本文整理匯總了TypeScript中embark.Events.emit方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Events.emit方法的具體用法?TypeScript Events.emit怎麽用?TypeScript Events.emit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類embark.Events
的用法示例。
在下文中一共展示了Events.emit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
this.registerEmbarkJs((err?: Error | null) => {
if (err) {
return this.logger.error(err);
}
this.providerReady = true;
this.events.emit("console:provider:done");
});
示例2: saveHistory
private saveHistory(cmd: string, fromIpcClient = false) {
const history = this.history;
if (fromIpcClient) {
if (history[history.length - 1] !== cmd) {
history.push(cmd);
}
this.events.emit("console:history:save", cmd);
return this.ipc.broadcast("console:history:save", cmd, true);
}
history.push(cmd);
if (this.ipc.isServer()) {
this.ipc.broadcast("console:history:save", cmd, true);
} else if (this.ipc.connected) {
this.ipc.client.emit("console:history:save", cmd);
}
if (this.fs.existsSync(dirname(this.cmdHistoryFile))) {
this.fs.writeFileSync(
this.cmdHistoryFile,
history
.slice(Math.max(0, history.length - this.cmdHistorySize()))
.reverse()
.filter((line: string) => line.trim())
.join("\n"),
);
}
}