GoogleChromeLabs / carlo

Web rendering surface for Node applications
Apache License 2.0
9.31k stars 309 forks source link

eventEmitter not working after app.load() #52

Closed grepug closed 5 years ago

grepug commented 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);
  }
}
pavelfeldman commented 5 years ago

Dupe of #50