Skip to content

Instantly share code, notes, and snippets.

@Elmuti
Created May 24, 2015 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elmuti/4c8d2bf23cb9e6f3e27d to your computer and use it in GitHub Desktop.
Save Elmuti/4c8d2bf23cb9e6f3e27d to your computer and use it in GitHub Desktop.
local Signal = {}
local mobj = require("System/Libraries/ModObject")
function Signal.New()
local sig = Signal:Init()
sig.connection = nil
return sig
end
function Signal:Connect(f)
self.connection = f
end
function Signal:Disconnect()
self.connection = nil
end
function Signal:Fire(...)
if self.connection ~= nil then
self.connection(...)
end
end
return mobj:NewClass("Signal", nil, Signal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment