From c789d9a4e456e6beadcfd862e7c59d3664de8815 Mon Sep 17 00:00:00 2001 From: Amero-EOF <60054103+Amero-EOF@users.noreply.github.com> Date: Wed, 25 Sep 2024 05:53:34 -0400 Subject: [PATCH 1/3] Added destructor to Trove:BindToRenderStep --- modules/trove/init.luau | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/trove/init.luau b/modules/trove/init.luau index 7bd29174..52513406 100644 --- a/modules/trove/init.luau +++ b/modules/trove/init.luau @@ -7,7 +7,7 @@ export type Trove = { Clone: (self: Trove, instance: T & Instance) -> T, Construct: (self: Trove, class: Constructable, A...) -> T, Connect: (self: Trove, signal: SignalLike | RBXScriptSignal, fn: (...any) -> ...any) -> ConnectionLike, - BindToRenderStep: (self: Trove, name: string, priority: number, fn: (dt: number) -> ()) -> (), + BindToRenderStep: (self: Trove, name: string, priority: number, fn: (dt: number) -> ()) -> () -> (), AddPromise: (self: Trove, promise: T & PromiseLike) -> T, Add: (self: Trove, object: T & Trackable, cleanupMethod: string?) -> T, Remove: (self: Trove, object: T & Trackable) -> boolean, @@ -347,8 +347,10 @@ end @param name string @param priority number @param fn (dt: number) -> () + @return ()->() Calls `RunService:BindToRenderStep` and registers a function in the - trove that will call `RunService:UnbindFromRenderStep` on cleanup. + trove that will call `RunService:UnbindFromRenderStep` on cleanup. It + also returns the registered function for cleanup with `Trove:Remove`. ```lua trove:BindToRenderStep("Test", Enum.RenderPriority.Last.Value, function(dt) @@ -362,10 +364,13 @@ function Trove.BindToRenderStep(self: TroveInternal, name: string, priority: num end RunService:BindToRenderStep(name, priority, fn) - - self:Add(function() + + local destructor = function() RunService:UnbindFromRenderStep(name) - end) + end + + self:Add(destructor) + return destructor end --[=[ From 40d7f83e9ea26d2db547e6daa7e28d71af66ef41 Mon Sep 17 00:00:00 2001 From: Amero-EOF <60054103+Amero-EOF@users.noreply.github.com> Date: Wed, 25 Sep 2024 05:54:28 -0400 Subject: [PATCH 2/3] Fixed improper spacing --- modules/trove/init.luau | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/trove/init.luau b/modules/trove/init.luau index 52513406..f191caff 100644 --- a/modules/trove/init.luau +++ b/modules/trove/init.luau @@ -347,7 +347,7 @@ end @param name string @param priority number @param fn (dt: number) -> () - @return ()->() + @return () -> () Calls `RunService:BindToRenderStep` and registers a function in the trove that will call `RunService:UnbindFromRenderStep` on cleanup. It also returns the registered function for cleanup with `Trove:Remove`. From 5a82a1957fe8323e25d48cd56e42f4b0533cf8ad Mon Sep 17 00:00:00 2001 From: Amero-EOF <60054103+Amero-EOF@users.noreply.github.com> Date: Wed, 25 Sep 2024 06:11:29 -0400 Subject: [PATCH 3/3] Fix for StyleLua --- modules/trove/init.luau | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/trove/init.luau b/modules/trove/init.luau index f191caff..c8def0a8 100644 --- a/modules/trove/init.luau +++ b/modules/trove/init.luau @@ -364,11 +364,9 @@ function Trove.BindToRenderStep(self: TroveInternal, name: string, priority: num end RunService:BindToRenderStep(name, priority, fn) - local destructor = function() RunService:UnbindFromRenderStep(name) end - self:Add(destructor) return destructor end