lua-events

Node style events for Lua

lua-events

Node style events for Lua

Setup lua-loader and then just npm install lua-events

local EventEmitter = require("lua-events").EventEmitter
local myObj = EventEmitter:new({text = "Hello, world!"})
function myObj:talk ()
  self:emit("spoken", self:text)
end
myObj:on("spoken", function (text)
  print("myObj said", text)
end)
myObj:talk()
  • Not the complete Node EventEmitter interface; only on, emit, and listeners
  • Added in 0.0.5: listeners
  • Fixed in 0.0.4: protected against emitting events w/ no listener
  • New in 0.0.3: properly have an array of listeners per event in stead of just one

GNU Lesser General Public License (LGPL)