Eventable - A series of tubes for your Lua tables.

Hi,

I’ve put together a new Lua mod called Eventable. It’s basically a chat room for your tables and mods.

The module does not use any Corona based listeners, and does not rely on any ‘global’ space. Your tables are still just tables, with a couple extra methods.  The API is small and simple.

There are a lot of examples on the Eventable site, but just to show how simple it is.

[lua]

– Require Eventable

local et = require(‘Eventable’)

– A new evented table

local mytbl = et:new()

– Listen for the ‘game’ event

mytbl:on(‘game’, function( event, score, players, … )

  print( score, players )

end

– Send out a ‘greeting’ event.

mytbl:emit( ‘greeting’, 'Hello! ) 

[/lua]

Any evented table or module can communicate with any other, as long as they are listening for the event.

[lua]

– Require Eventable

local et = require(‘Eventable’)

– Generate a couple evented tables

local t1 = et:new()

local t2 = et:new()

t1 listenens

t1:on(‘greeting’, function( event, message )

  print( 'greeting: ’ … message )

end

t2 sends

t2:emit(‘greeting’, ‘Hello!’)

–> greeting: Hello!

[/lua]

Visit the Eventable  project site for more examples, including intra-module communication. You can also jump to the API here.

Testing, feedback, bug reporting highly appreciated.

Cheers.

Hello, nice :D, great work!

The listeners overwrite itself?

Example:

  • t1 add listener “greeting”

  • t2 emit “greeting” // call t1.greeting

  • t2 add listener “greeting”

  • t2 emit “greeting” // ???

  • t1 emit “greeting” // ???

Thanks. :slight_smile:

Hi,

I’ll take a look. Please file all issues for Eventable here https://github.com/develephant/Eventable/issues/new

Thanks!

There’s no an issue, its only a question, haha.  :stuck_out_tongue:

I have yet to try it but looks extremely cool and well done. Thanks!

Hello, nice :D, great work!

The listeners overwrite itself?

Example:

  • t1 add listener “greeting”

  • t2 emit “greeting” // call t1.greeting

  • t2 add listener “greeting”

  • t2 emit “greeting” // ???

  • t1 emit “greeting” // ???

Thanks. :slight_smile:

Hi,

I’ll take a look. Please file all issues for Eventable here https://github.com/develephant/Eventable/issues/new

Thanks!

There’s no an issue, its only a question, haha.  :stuck_out_tongue:

I have yet to try it but looks extremely cool and well done. Thanks!