Skip to main content

Cleaner

The package's cleanup bag. Add what must be released, and Destroy releases it all in reverse order: instances, connections, threads, functions, and anything with Destroy or Disconnect. Your own cleanup helper works with the package too, as long as it calls Destroy.

Functions​

new​

Cleaner.new() → Cleaner

Add​

Cleaner.Add(
self: Cleaner,
object: T,--

An Instance, connection, function, thread, or a table with Destroy or Disconnect.

method: string?--

The method to call instead of the usual one, for a table with an unusual name.

) → T--

The same object, so local part = cleaner:Add(Instance.new("Part")) reads well.

Errors

TypeDescription
stringThe object is of a kind the cleaner cannot release, or the cleaner was destroyed.

Connect​

Cleaner.Connect(
self: Cleaner,
signal: any,--

Anything with Connect: an RBXScriptSignal or a Types.Signal.

handler: (...any) → ()
) → any--

The connection, already added.

Extend​

Cleaner.Extend(self: Cleaner) → Cleaner--

A child cleaner, cleaned with this one, usable on its own before that.

Remove​

Cleaner.Remove(
self: Cleaner,
object: any
) → boolean--

true when it was held.

Takes an object back out and releases it.

Clean​

Cleaner.Clean(self: Cleaner) → ()

Releases everything, newest first, and leaves the cleaner usable. An object that errors on release is warned about and the rest are still released.

Destroy​

Cleaner.Destroy(self: Cleaner) → ()

Clean, then refuse anything new.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Cleaner"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 72,
                "path": "lib/Utility/Cleaner.luau"
            }
        },
        {
            "name": "Add",
            "desc": "",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Cleaner"
                },
                {
                    "name": "object",
                    "desc": "An Instance, connection, function, thread, or a table with `Destroy` or `Disconnect`.",
                    "lua_type": "T"
                },
                {
                    "name": "method",
                    "desc": "The method to call instead of the usual one, for a table with an unusual name.",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "The same object, so `local part = cleaner:Add(Instance.new(\"Part\"))` reads well.",
                    "lua_type": "T"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "string",
                    "desc": "The object is of a kind the cleaner cannot release, or the cleaner was destroyed."
                }
            ],
            "source": {
                "line": 89,
                "path": "lib/Utility/Cleaner.luau"
            }
        },
        {
            "name": "Connect",
            "desc": "",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Cleaner"
                },
                {
                    "name": "signal",
                    "desc": "Anything with `Connect`: an `RBXScriptSignal` or a [Types.Signal].",
                    "lua_type": "any"
                },
                {
                    "name": "handler",
                    "desc": "",
                    "lua_type": "(...any) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "The connection, already added.",
                    "lua_type": "any"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 121,
                "path": "lib/Utility/Cleaner.luau"
            }
        },
        {
            "name": "Extend",
            "desc": "",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Cleaner"
                }
            ],
            "returns": [
                {
                    "desc": "A child cleaner, cleaned with this one, usable on its own before that.",
                    "lua_type": "Cleaner"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 129,
                "path": "lib/Utility/Cleaner.luau"
            }
        },
        {
            "name": "Remove",
            "desc": "Takes an object back out and releases it.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Cleaner"
                },
                {
                    "name": "object",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "`true` when it was held.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 140,
                "path": "lib/Utility/Cleaner.luau"
            }
        },
        {
            "name": "Clean",
            "desc": "Releases everything, newest first, and leaves the cleaner usable. An object that errors on\nrelease is warned about and the rest are still released.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Cleaner"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 159,
                "path": "lib/Utility/Cleaner.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "`Clean`, then refuse anything new.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Cleaner"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 182,
                "path": "lib/Utility/Cleaner.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Cleaner",
    "desc": "The package's cleanup bag. Add what must be released, and `Destroy` releases it all in\nreverse order: instances, connections, threads, functions, and anything with `Destroy` or\n`Disconnect`. Your own cleanup helper works with the package too, as long as it calls\n`Destroy`.",
    "source": {
        "line": 67,
        "path": "lib/Utility/Cleaner.luau"
    }
}