Manages the cleaning of events and other things.

Useful for encapsulating state and make deconstructors easy

See also

Members

Functions

Returns Functions Description
Maid Maid.new ( ) Returns a new Maid object

Metamethods

Metamethods Description
__index ( index ) Returns Maid[key] if not part of Maid metatable
__newindex ( index newTask ) Add a task to clean up

Methods

Returns Methods Description
number GiveTask ( task ) Same as indexing, but uses an incremented number as a key.
DoCleaning ( ) Cleans up all tasks.
Destroy ( ) Alias for DoCleaning()

Functions Descriptions

Maid Maid.new ( )

Returns a new Maid object Maid.new()

Returns

Metamethods Descriptions

Maid:__index ( index )

Returns Maid[key] if not part of Maid metatable

Parameters

  • index

Returns

  • Maid[key] value

Maid:__newindex ( index newTask )

Add a task to clean up

Parameters

  • index
  • newTask

Usage

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.

Methods Descriptions

number Maid:GiveTask ( task )

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

Parameters

  • task: An item to clean

Returns

Maid:DoCleaning ( )

Cleans up all tasks.

Maid:Destroy ( )

Alias for DoCleaning()