Skip to main content

Bucket

Used for cleanup of various data types and instances.

Functions

new

Bucket.new() → Bucket

Creates a new bucket instance.

local BucketInstance = Bucket.new()

BucketInstance:Add(...)
BucketInstance:Remove(...)
BucketInstance:Destroy()

Add

Bucket:Add(
Objectany,--

The object to be cleaned up

CleanupMethodNamestring?--

If you're passing a table, this is an optional setting to choose the cleanup function name (defaults to Destroy or Disconnect)

) → any--

The object you inputted

Adds userdata or an instance to the bucket. Supported types include: Instance, RBXScriptConnection, function, thread, or table.

local BucketInstance = Bucket.new()

BucketInstance:Add(workspace.Baseplate)

BucketInstance:Add(RunService.RenderStepped:Connect(function()
	-- ...
end))

BucketInstance:Add(function()
	-- ...
end)

AddPromise

Bucket:AddPromise(
ObjectPromise--

The promise to be cleaned up

) → Promise--

The same promise that was inputted

Adds a promise to the bucket. Will return the promise, meaning it can be chained.

-- local MyPromise = ...

local BucketInstance = Bucket.new()

BucketInstance:AddPromise(MyPromise)

AttachToInstance

Bucket:AttachToInstance(
ObjectInstance--

The instance to track

) → ()

Tells the Bucket to destroy itself when the inputted instance is destroyed or parented to nil.

local BucketInstance = Bucket.new()

BucketInstance:AttachToInstance(PartInstance)

Extend

Bucket:Extend() → Bucket--

The sub-Bucket

Creates another Bucket and adds it to this (the parent) one.

local BucketInstance = Bucket.new()

local SubBucketInstance = BucketInstance:Extend()

Remove

Bucket:Remove(
Objectany--

The object to be removed from cleanup

) → ()

Removes an object from Bucket's cleanup.

local BucketInstance = Bucket.new()

BucketInstance:Add(Value)
BucketInstance:Remove(Value) -- No longer cleaned up

GetWrappedDestroy

Bucket:GetWrappedDestroy() → () → nil

Returns a function that, when called, destroys the Bucket.

local BucketInstance = Bucket.new()

local Destroy = BucketInstance:GetWrappedDestroy()

Destroy()

Destroy

Bucket:Destroy() → ()

Destroys the Bucket, cleaning up all objects and promises inside of it.

local BucketInstance = Bucket.new()

-- Add stuff...

BucketInstance:Destroy()
Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new bucket instance.\n\n```lua\nlocal BucketInstance = Bucket.new()\n\nBucketInstance:Add(...)\nBucketInstance:Remove(...)\nBucketInstance:Destroy()\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Bucket"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 88,
                "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
            }
        },
        {
            "name": "Add",
            "desc": "Adds userdata or an instance to the bucket. Supported types include: Instance, RBXScriptConnection, function, thread, or table.\n\n```lua\nlocal BucketInstance = Bucket.new()\n\nBucketInstance:Add(workspace.Baseplate)\n\nBucketInstance:Add(RunService.RenderStepped:Connect(function()\n\t-- ...\nend))\n\nBucketInstance:Add(function()\n\t-- ...\nend)\n```",
            "params": [
                {
                    "name": "Object",
                    "desc": "The object to be cleaned up",
                    "lua_type": "any"
                },
                {
                    "name": "CleanupMethodName",
                    "desc": "If you're passing a table, this is an optional setting to choose the cleanup function name (defaults to Destroy or Disconnect)",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "The object you inputted",
                    "lua_type": "any"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 119,
                "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
            }
        },
        {
            "name": "AddPromise",
            "desc": "Adds a promise to the bucket. Will return the promise, meaning it can be chained.\n\n```lua\n-- local MyPromise = ...\n\nlocal BucketInstance = Bucket.new()\n\nBucketInstance:AddPromise(MyPromise)\n```",
            "params": [
                {
                    "name": "Object",
                    "desc": "The promise to be cleaned up",
                    "lua_type": "Promise"
                }
            ],
            "returns": [
                {
                    "desc": "The same promise that was inputted",
                    "lua_type": "Promise"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 142,
                "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
            }
        },
        {
            "name": "AttachToInstance",
            "desc": "Tells the Bucket to destroy itself when the inputted instance is destroyed or parented to nil.\n\n```lua\nlocal BucketInstance = Bucket.new()\n\nBucketInstance:AttachToInstance(PartInstance)\n```",
            "params": [
                {
                    "name": "Object",
                    "desc": "The instance to track",
                    "lua_type": "Instance"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 176,
                "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
            }
        },
        {
            "name": "Extend",
            "desc": "Creates another Bucket and adds it to this (the parent) one.\n\n```lua\nlocal BucketInstance = Bucket.new()\n\nlocal SubBucketInstance = BucketInstance:Extend()\n```",
            "params": [],
            "returns": [
                {
                    "desc": "The sub-Bucket",
                    "lua_type": "Bucket"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 204,
                "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
            }
        },
        {
            "name": "Remove",
            "desc": "Removes an object from Bucket's cleanup.\n\n```lua\nlocal BucketInstance = Bucket.new()\n\nBucketInstance:Add(Value)\nBucketInstance:Remove(Value) -- No longer cleaned up\n```",
            "params": [
                {
                    "name": "Object",
                    "desc": "The object to be removed from cleanup",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 229,
                "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
            }
        },
        {
            "name": "GetWrappedDestroy",
            "desc": "Returns a function that, when called, destroys the Bucket.\n\n```lua\nlocal BucketInstance = Bucket.new()\n\nlocal Destroy = BucketInstance:GetWrappedDestroy()\n\nDestroy()\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "() -> nil"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 251,
                "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Destroys the Bucket, cleaning up all objects and promises inside of it.\n\n```lua\nlocal BucketInstance = Bucket.new()\n\n-- Add stuff...\n\nBucketInstance:Destroy()\n```",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 269,
                "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Bucket",
    "desc": "Used for cleanup of various data types and instances.",
    "source": {
        "line": 6,
        "path": "src/Packages/_Index/miagobble_bucket@1.0.1/bucket/init.luau"
    }
}