diff --git a/README.md b/README.md index 59149da7..252f17b3 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/modules/signal/init.lua b/modules/signal/init.lua index 5f0154a1..54473fca 100644 --- a/modules/signal/init.lua +++ b/modules/signal/init.lua @@ -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!") ``` ]=] diff --git a/modules/trove/init.lua b/modules/trove/init.lua index 2151e5a0..19578c91 100644 --- a/modules/trove/init.lua +++ b/modules/trove/init.lua @@ -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") @@ -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) @@ -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:()` | Returns the object added. diff --git a/modules/trove/wally.toml b/modules/trove/wally.toml index 7b2fcd64..5960e8f1 100644 --- a/modules/trove/wally.toml +++ b/modules/trove/wally.toml @@ -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"