Awesome
lua-events
Node style events for Lua
Usage
1. Install
Setup lua-loader and then just npm install lua-events
2. Require
local EventEmitter = require("lua-events").EventEmitter
3. Have fun
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()
Limitations
- Not the complete Node EventEmitter interface; only
on
,emit
, andlisteners
History
- 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