lua-events

0.0.5 • Public • Published

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, and listeners

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

License

GNU Lesser General Public License (LGPL)

Readme

Keywords

none

Package Sidebar

Install

npm i lua-events

Weekly Downloads

6

Version

0.0.5

License

LGPL

Last publish

Collaborators

  • wscherphof