Closed grepug closed 5 years ago
const carlo = require("carlo"); const { EventEmitter } = require("events"); (async () => { app = await carlo.launch(); app.on("exit", () => process.exit()); app.serveFolder(__dirname); await app.exposeFunction("env", _ => process.env); const api = new Api(); api.on("h", console.log); // only log 1 await app.exposeObject("api", api); api.hello(1); // works await app.load("index.html"); api.hello(2); // not working })(); class Api extends EventEmitter { hello(data) { this.emit("h", data); } }
Dupe of #50