deoxxa / jsmc

Pure JavaScript Minecraft server
Other
82 stars 14 forks source link

Interruptible Event Layer #11

Open deoxxa opened 11 years ago

deoxxa commented 11 years ago

Certain events require more advanced flow control than "call a bunch of listeners" (see https://github.com/deoxxa/jsmc/pull/10 for an example).

I think we need an event library that implements something similar to stopPropagation for this, so the following becomes possible:

player.on("chat", function(message, ev) {
  if (message.length > 0 && message[0] === "/") {
    player.emit("command", message.substr(1));
    ev.stopPropagation();
  }
});