Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/component-start
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleitnick authored Nov 25, 2023
2 parents 08027ea + 135fcb9 commit ae92f7b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
| [TaskQueue](https://sleitnick.github.io/RbxUtil/api/TaskQueue) | `TaskQueue = "sleitnick/task-queue@1.0.0"` | Batches tasks that occur on the same execution step |
| [Timer](https://sleitnick.github.io/RbxUtil/api/Timer) | `Timer = "sleitnick/timer@1.1.2"` | Timer class |
| [Tree](https://sleitnick.github.io/RbxUtil/api/Tree) | `Tree = "sleitnick/tree@1.1.0"` | Utility functions for accessing instances in the game hierarchy |
| [Trove](https://sleitnick.github.io/RbxUtil/api/Trove) | `Trove = "sleitnick/trove@1.0.1"` | Trove class for tracking and cleaning up objects |
| [Trove](https://sleitnick.github.io/RbxUtil/api/Trove) | `Trove = "sleitnick/trove@1.1.0"` | Trove class for tracking and cleaning up objects |
| [WaitFor](https://sleitnick.github.io/RbxUtil/api/WaitFor) | `WaitFor = "sleitnick/wait-for@1.0.0"` | WaitFor class for awaiting instances |
8 changes: 7 additions & 1 deletion modules/signal/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,22 @@ setmetatable(Connection, {
--[=[
@class Signal
Signals allow events to be dispatched and handled.
A Signal is a data structure that allows events to be dispatched
and observed.
This implementation is a direct copy of the de facto standard, [GoodSignal](https://devforum.roblox.com/t/lua-signal-class-comparison-optimal-goodsignal-class/1387063),
with some added methods and typings.
For example:
```lua
local signal = Signal.new()
-- Subscribe to a signal:
signal:Connect(function(msg)
print("Got message:", msg)
end)
-- Dispatch an event:
signal:Fire("Hello world!")
```
]=]
Expand Down
11 changes: 6 additions & 5 deletions modules/trove/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

local FN_MARKER = newproxy()
local THREAD_MARKER = newproxy()
local GENERIC_OBJECT_CLEANUP_METHODS = { "Destroy", "Disconnect", "destroy", "disconnect" }

local RunService = game:GetService("RunService")

Expand All @@ -22,10 +23,10 @@ local function GetObjectCleanupFunction(object, cleanupMethod)
elseif t == "RBXScriptConnection" then
return "Disconnect"
elseif t == "table" then
if typeof(object.Destroy) == "function" then
return "Destroy"
elseif typeof(object.Disconnect) == "function" then
return "Disconnect"
for _, genericCleanupMethod in GENERIC_OBJECT_CLEANUP_METHODS do
if typeof(object[genericCleanupMethod]) == "function" then
return genericCleanupMethod
end
end
end
error("Failed to get cleanup function for object " .. t .. ": " .. tostring(object), 3)
Expand Down Expand Up @@ -245,7 +246,7 @@ end
| `RBXScriptConnection` | `object:Disconnect()` |
| `function` | `object()` |
| `thread` | `task.cancel(object)` |
| `table` | `object:Destroy()` _or_ `object:Disconnect()` |
| `table` | `object:Destroy()` _or_ `object:Disconnect()` _or_ `object:destroy()` _or_ `object:disconnect()` |
| `table` with `cleanupMethod` | `object:<cleanupMethod>()` |
Returns the object added.
Expand Down
2 changes: 1 addition & 1 deletion modules/trove/wally.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sleitnick/trove"
description = "Trove class for tracking and cleaning up objects"
version = "1.0.1"
version = "1.1.0"
license = "MIT"
authors = ["Stephen Leitnick"]
registry = "https://github.com/UpliftGames/wally-index"
Expand Down

0 comments on commit ae92f7b

Please sign in to comment.