Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joshtynjala/signal.lua

Signals are a light-weight messaging tools for Lua and the Corona SDK.
https://github.com/joshtynjala/signal.lua

lua signals

Last synced: 4 months ago
JSON representation

Signals are a light-weight messaging tools for Lua and the Corona SDK.

Awesome Lists containing this project

README

        

h1. signal.lua

A simple implementation of Signals for Lua and Ansca's Corona SDK by "Josh Tynjala":http://twitter.com/joshtynjala. Inspired by "as3-signals":https://github.com/robertpenner/as3-signals, the ActionScript implementation by "Robert Penner":http://twitter.com/robpenner.

h2. Usage

bc.. local signal = require("signal")

local function onSignalListener(message)
-- prints "signal says: hello! nil"
print("signal says:", message, self)
end

local myTable = {}
function myTable:method(message)
-- prints "signal says: hello! table: ########"
print("signal says:", message, self)
end

local onSignal = signal.new()
onSignal:add(onSignalListener) --no scope
onSignal:add(myTable.method, myTable) --include scope
onSignal:dispatch("hello!")