Repository navigation
2. API
Creates a recycler object!
Adds an object to weak garbage, it can still be garbage collected by Lua, however it will stay on a temporary storage until then.
This method accepts MULTIPLE objects at once, it will insert them for you.
Adds an object to a strong garbage, the object passed will never be garbage collected, it can only be garbage collected if the recycler object gets collected, or if an object was re-used from it.
This method accepts MULTIPLE objects at once, it will insert them for you.
Returns an object if there is one to reuse.
It can return an object if there if there's a
:OnNewObjecthandler which returns one. You can read about it below.
Returns an array with the amount of objects asked for.
createNewObjectsdefaults to true if unspecified, you don't need to tell it explicitly.
In case if either
createNewObjectsis false, or there is no:OnNewObjecthandler, and there's no objects to reuse, the array might not return that amount of objects, instead it will only return the ones it was able to re-use.
Sets a handler function to when there is no available object to re-use on :GetObject,
whatever it returns will be returned on :GetObject when there is no object to re-use.
Sets a handler for when :GetObject is called, and there is an object to reuse,
this should be used to prepare an object for when it needs to be reused.
Despite the name,
:OnDestroyedlike stayed above, doesn't fire when an object is added to garbage, instead it fires on:GetObjectif there's an object to re-use. Therefore, if you need to change things when an object is destroyed, change it before sending it to the garbage. Most use-cases won't require this to be a thing, therefore this is an optimization.