Skip to main content

Maid

Manages the cleaning of events and other things. Useful for encapsulating state and make deconstructors easy

Functions

new

Maid.new() → Maid

Returns a new Maid object

Destroy

Maid.Destroy() → ()

Alias for DoCleaning()

__index

Maid:__index(indexany) → Maid[key]any

Returns Maid[key] if not part of Maid metatable

__newindex

Maid:__newindex(
indexany,
newTaskany
) → ()

Add a task to clean up Maid[key] = (function) Adds a task to perform Maid[key] = (event connection) Manages an event connection Maid[key] = (Maid) Maids can act as an event connection, allowing a Maid to have other maids to clean up. Maid[key] = (Object) Maids can cleanup objects with a Destroy method Maid[key] = nil Removes a named task. If the task is an event, it is disconnected. If it is an object, it is destroyed.

GiveTask

Maid:GiveTask(
taskany--

An item to clean

) → number--

taskId

Same as indexing, but uses an incremented number as a key.

GivePromise

Maid:GivePromise(promisePromise) → ()

Gives a promise to be cleaned

DoCleaning

Maid:DoCleaning() → ()

Cleans up all tasks.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Returns a new Maid object",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Maid"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 10,
                "path": "src/shared/modules/Maid.lua"
            }
        },
        {
            "name": "__index",
            "desc": "Returns Maid[key] if not part of Maid metatable",
            "params": [
                {
                    "name": "index",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Maid[key] any"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 21,
                "path": "src/shared/modules/Maid.lua"
            }
        },
        {
            "name": "__newindex",
            "desc": "Add a task to clean up\nMaid[key] = (function)\t\t\tAdds a task to perform\nMaid[key] = (event connection)\tManages an event connection\nMaid[key] = (Maid)\t\t\t\tMaids can act as an event connection, allowing a Maid to have other maids to clean up.\nMaid[key] = (Object)\t\t\tMaids can cleanup objects with a `Destroy` method\nMaid[key] = nil\t\t\t\t\tRemoves a named task. If the task is an event, it is disconnected. If it is an object, it is destroyed.",
            "params": [
                {
                    "name": "index",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "newTask",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 37,
                "path": "src/shared/modules/Maid.lua"
            }
        },
        {
            "name": "GiveTask",
            "desc": "Same as indexing, but uses an incremented number as a key.",
            "params": [
                {
                    "name": "task",
                    "desc": "An item to clean",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "taskId",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 60,
                "path": "src/shared/modules/Maid.lua"
            }
        },
        {
            "name": "GivePromise",
            "desc": "Gives a promise to be cleaned",
            "params": [
                {
                    "name": "promise",
                    "desc": "",
                    "lua_type": "Promise"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 74,
                "path": "src/shared/modules/Maid.lua"
            }
        },
        {
            "name": "DoCleaning",
            "desc": "Cleans up all tasks.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 91,
                "path": "src/shared/modules/Maid.lua"
            }
        },
        {
            "name": "Destroy",
            "desc": "Alias for DoCleaning()",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 120,
                "path": "src/shared/modules/Maid.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Maid",
    "desc": "Manages the cleaning of events and other things.\nUseful for encapsulating state and make deconstructors easy",
    "source": {
        "line": 4,
        "path": "src/shared/modules/Maid.lua"
    }
}