한국어 👈
This is a fork of LemonSignal with some extra features added and some unnecessary parts removed.
- Added
ImmutableEvent
(its connections are intended to be immutable from outside) - Renamed
connectOnce
toonce
. Bindable.event
is nowImmutableEvent
.- Sligtly, a little bit more micro optimized.
- Added better error messages.
- Added english version of README.
- In theory, performance and speed are not as good as
LemonSignal
. - You can use the package
caveful_games/threadpool
to keep threads in a single shared threadpool space. - Added several useful classes from
LemonSignal
. - All class methods and properties are in camelCase. Note that the methods in the original
RBXScriptSignal
andSignal
modules were in PascalCase. - Pure luau support has been removed (LimeSignal is Roblox only).
- NOTE: This package is no longer updated for
wally
.
pesde add caveful_games/limesignal
local sig = limesignal.Signal.new()
sig:connect(function()
-- do something
end)
sig:fire()
-- API inspired by roblox's BindableEvent instance
local bindable = limesignal.Bindable.new()
bindable.event:connect(function()
-- do something
end)
bindable:fire()
-- Useful when you want to make event's `fire` method into private!
local Class = {}
local emit = limesignal.createEmitter()
function Class.new()
return setmetatable({
onSomething = limesignal.Event.from(emit) :: limesignal.Event<number, string>
}, Class)
end
function Class.something(self)
emit(self.onSomething, 123, "hi") -- ofc typed!
end
local object = Class.new()
object.onSomething:connect(function(a, b) -- typed!
print(a, b) -- 123, "hi"
end)
object:something()
object.onSomething:fire() -- no you can't
-- Useful when you want to make event's `fire` method into private! but intended to be immutable connections from outside.
-- DisconnectAll(=destroy) internally using destroyer!
local Class = {}
local destroy = limesignal.createDestroyer()
local emit = limesignal.createEmitter()
function Class.new()
return setmetatable({
onSomething = limesignal.ImmutableEvent.from(emit, destroy) :: limesignal.ImmutableEvent<number, string>
}, Class)
end
function Class.something(self)
destroy(self.onSomething) -- disconnects all connections from ImmutableEvent
end
local object = Class.new()
object.onSomething:once(function(a, b) -- typed!
print(a, b) -- 123, "hi"
end)
object.onSomething:fire() -- no you can't
object.onSomething:disconnectAll() -- no you can't
object:something()