Skip to content

Commit

Permalink
Fixed :Fire error
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspecky committed Mar 27, 2024
1 parent 2301d9b commit 20dd450
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"luau-lsp.sourcemap.rojoProjectFile": "place.project.json"
}
2 changes: 1 addition & 1 deletion sourcemap.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"LuauEvent","className":"ModuleScript","filePaths":["src/LuauEvent.lua","default.project.json"]}
{"name":"project","className":"DataModel","filePaths":["place.project.json"],"children":[{"name":"ReplicatedStorage","className":"ReplicatedStorage","children":[{"name":"LuauEvent","className":"ModuleScript","filePaths":["src/LuauEvent.lua","default.project.json"]}]},{"name":"ServerScriptService","className":"ServerScriptService","children":[{"name":"tests","className":"Folder","children":[{"name":"test.story","className":"ModuleScript","filePaths":["tests\\test.story.lua"]},{"name":"wrap.story","className":"ModuleScript","filePaths":["tests\\wrap.story.lua"]}]}]}]}
8 changes: 4 additions & 4 deletions src/LuauEvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export type Connection<U...> = {
}

export type Signal<T...> = {
Connect: <U...>(self: Signal<T...>, fn: (...unknown) -> (), U...) -> Connection<U...>,
Once: <U...>(self: Signal<T...>, fn: (...unknown) -> (), U...) -> Connection<U...>,
Connect: <U...>(self: Signal<T...>, fn: (...any) -> (), U...) -> Connection<U...>,
Once: <U...>(self: Signal<T...>, fn: (...any) -> (), U...) -> Connection<U...>,
Wait: (self: Signal<T...>) -> T...,
}

Expand Down Expand Up @@ -150,7 +150,7 @@ local function Fire(self, ...)
end

if not cn._varargs then
task.spawn(thread, cn._fn, ...)
task.spawn(thread, cn._fn, thread, ...)
else
local args = cn._varargs
local len = #args
Expand All @@ -160,7 +160,7 @@ local function Fire(self, ...)
args[count] = value
end

task.spawn(thread, cn._fn, table.unpack(args))
task.spawn(thread, cn._fn, thread, table.unpack(args))

for i = count, len + 1, -1 do
args[i] = nil
Expand Down
16 changes: 16 additions & 0 deletions tests/test.story.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LuauEvent = require(ReplicatedStorage.LuauEvent)

return function()
local event = LuauEvent.new()

event.Event:Connect(function(...)
print(...) --> 1 2 3
end, 1)

event:Fire(2, 3)

return function()
event:Destroy()
end
end
18 changes: 18 additions & 0 deletions tests/wrap.story.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LuauEvent = require(ReplicatedStorage.LuauEvent)

return function()
local bindable = Instance.new("BindableEvent")
local event = LuauEvent.wrap(bindable.Event)

event.Event:Connect(function(...)
print(...) --> 1 2 3
end, 1)

bindable:Fire(2, 3)

return function()
bindable:Destroy()
event:Destroy()
end
end
2 changes: 1 addition & 1 deletion wally.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aspecky/luauevent"
version = "1.2.0"
version = "1.3.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
author = "Aspecky"
Expand Down

0 comments on commit 20dd450

Please sign in to comment.