Module collection
An interface for managing groups of objects that belong to a parent.
Collection extends Object
| owner |
The parent object of the collection. |
Properties
Properties.
Significant fields on an instance.
-
owner
-
The parent object of the collection.
Class Methods
Class Methods.
Must be called on
Class, with a capital leading character.
e.g.
Class:method("foo")
-
Collection:new (owner)
-
Create a new
Collection
Parameters:
Returns:
Collection
Instance Methods
Instance Methods.
Must be called on an instance of
Class.
e.g.
instance:method("foo")
-
collection:add (member, ...)
-
Add a member to the
Collection. This caches the member
so it doesn't get garbage collected prematurely. It also calls the
adder hook with any variable arguments.
Parameters:
- member
The member to add to the collection
- ...
Arguments to be passed to adder
Returns:
Whatever
adder returns
-
collection:remove (member, ...)
-
Remove a member from the
Collection. This removes the
member from the cache so it can get garbage collected. It also calls
the remove hook with any variable arguments.
Parameters:
- member
The member to remove the collection
- ...
Arguments to be passed to remover
Returns:
Whatever
remover returns
Hooks
Hooks.
Callbacks implemented in subclasses to customize behavior. Hooks are called
on individual instances.
-
adder (owner, member, ...)
-
Called when a member is added to the collection.
Parameters:
- owner
The owner of the collection
- member
The member being added
- ...
Any other arguments passed to collection:add
-
remover (owner, member, ...)
-
Called when a member is removed from the collection.
Parameters:
- owner
The owner of the collection
- member
The member being removed
- ...
Any other arguments passed to collection:remove