Skip to content

Commit b4ed78b

Browse files
committed
.
1 parent 91d9253 commit b4ed78b

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

src/Features/Cleanup/Janitor.lua

+30-6
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,30 @@ local function getJanitors()
1313
return require(script.Parent).Janitors
1414
end
1515

16-
--- @class Janitor
17-
--- Another class.
18-
19-
16+
--[=[
17+
@class Janitor
18+
@tag Advanced
19+
This is an external class which can be referenced with `MapLib:GetFeature("Cleanup").Janitor`
20+
21+
Janitor is destructor based class designed to assist with clearing up connections events and references.
22+
:::warning
23+
WARNING! This is an advanced feature.
24+
This page assumes you are familiar, comfortable and can write Luau code.
25+
:::
26+
]=]
2027
--[=[
2128
@within Janitor
2229
@since 0.11
30+
2331
@function new
2432
@param name string?
2533
@return _tasks: {[string]: any}
2634
@return context: string
2735
@return name: string?
2836
@return index: number | string
37+
@return __index: Janitor
38+
39+
Constructs a new Janitor class and is cached for later use. Janitor provides an option in case you want to name your Janitor for easier reference later.
2940
]=]
3041
function Janitor.new(janitorName: string?)
3142
local self = setmetatable({}, Janitor)
@@ -36,14 +47,19 @@ function Janitor.new(janitorName: string?)
3647
local janitors = getJanitors()
3748

3849
self.index = janitorName or #janitors + 1
39-
janitors[self.index ] = self
50+
janitors[self.index] = self
4051

4152
return self
4253
end
4354

4455
--[=[
45-
@since 0.11
56+
@within Janitor
57+
@since 0.11
58+
@function isJanitor
59+
@return boolean
60+
Returns true if the given class is a Janitor, if not it returns false.
4661
]=]
62+
4763
function Janitor.isJanitor(value: table?): boolean
4864
return type(value) == "table" and value.ClassName == "Janitor"
4965
end
@@ -54,7 +70,13 @@ end
5470
@method Give
5571
@param task <T>
5672
@return (<T>) -> <T>
73+
74+
This method is used to give Janitor tasks to cleanup, these tasks can be anything, some examples include, functions, threads, coroutines or anything with a .Destroy function.
75+
:::tip
76+
Janitor allows for tables to be given in as an argument. If Janitor detects a table it will loop through the table and add anything it finds will be added to the tasks table.
77+
:::
5778
]=]
79+
5880
function Janitor:Give(task: any)
5981
local function handleTask(subtask: any)
6082
assert(typeof(task) ~= "boolean", "Task cannot be a boolean")
@@ -85,6 +107,8 @@ end
85107
@method Cleanup
86108
@param taskTable: table?
87109
@return nil
110+
111+
Calls for the Janitor to cleanup up all the tasks it was given.
88112
]=]
89113
function Janitor:Cleanup(taskTable: table?)
90114
local tasks = taskTable or self._tasks

src/Features/Cleanup/init.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ end
1616

1717
--[=[
1818
@class Cleanup
19+
1920
This is the MapLib Feature. It can be accessed by `MapLib:GetFeature("Cleanup")`.
20-
21+
2122
Description of what this holds
23+
:::tip
24+
hi
25+
:::
2226
]=]
2327

2428
--[=[

0 commit comments

Comments
 (0)