@quenty/maid 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/maid@2.3.0...@quenty/maid@2.4.0) (2022-07-31)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Maid tasks cancel old threads upon rewrite ([f953eb8](https://github.com/Quenty/NevermoreEngine/commit/f953eb8650073a3da5b551239c87e8d9391bc858))
12
+
13
+
14
+ ### Features
15
+
16
+ * Add thread-support for maids ([#259](https://github.com/Quenty/NevermoreEngine/issues/259)) ([b6f37fa](https://github.com/Quenty/NevermoreEngine/commit/b6f37fa430dad4c6801510335c62691c4b7b6e3c))
17
+
18
+
19
+
20
+
21
+
6
22
  # [2.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/maid@2.2.0...@quenty/maid@2.3.0) (2022-03-27)
7
23
 
8
24
  **Note:** Version bump only for package @quenty/maid
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014-2021 Quenty
3
+ Copyright (c) 2014-2022 Quenty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/maid",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Easily cleanup event listeners and objects in Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -29,5 +29,5 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "gitHead": "501844bd6c3d3f765fd3032b997d8030bc963a1f"
32
+ "gitHead": "e31b3a35aa475bb5699a24898a8639e107165b36"
33
33
  }
@@ -88,6 +88,7 @@ end
88
88
  ```
89
89
  Maid[key] = (function) Adds a task to perform
90
90
  Maid[key] = (event connection) Manages an event connection
91
+ Maid[key] = (thread) Manages a thread
91
92
  Maid[key] = (Maid) Maids can act as an event connection, allowing a Maid to have other maids to clean up.
92
93
  Maid[key] = (Object) Maids can cleanup objects with a `Destroy` method
93
94
  Maid[key] = nil Removes a named task.
@@ -113,6 +114,8 @@ function Maid:__newindex(index, newTask)
113
114
  if oldTask then
114
115
  if type(oldTask) == "function" then
115
116
  oldTask()
117
+ elseif type(oldTask) == "thread" then
118
+ task.cancel(oldTask)
116
119
  elseif typeof(oldTask) == "RBXScriptConnection" then
117
120
  oldTask:Disconnect()
118
121
  elseif oldTask.Destroy then
@@ -197,6 +200,8 @@ function Maid:DoCleaning()
197
200
  tasks[index] = nil
198
201
  if type(job) == "function" then
199
202
  job()
203
+ elseif type(job) == "thread" then
204
+ task.cancel(job)
200
205
  elseif typeof(job) == "RBXScriptConnection" then
201
206
  job:Disconnect()
202
207
  elseif job.Destroy then
@@ -11,7 +11,7 @@
11
11
 
12
12
  --[=[
13
13
  An object that can be cleaned up
14
- @type MaidTask function | Destructable | RBXScriptConnection
14
+ @type MaidTask function | thread | Destructable | RBXScriptConnection
15
15
  @within MaidTaskUtils
16
16
  ]=]
17
17
  local MaidTaskUtils = {}
@@ -24,6 +24,7 @@ local MaidTaskUtils = {}
24
24
  ]=]
25
25
  function MaidTaskUtils.isValidTask(job)
26
26
  return type(job) == "function"
27
+ or type(job) == "thread"
27
28
  or typeof(job) == "RBXScriptConnection"
28
29
  or type(job) == "table" and type(job.Destroy) == "function"
29
30
  or typeof(job) == "Instance"
@@ -37,6 +38,8 @@ end
37
38
  function MaidTaskUtils.doTask(job)
38
39
  if type(job) == "function" then
39
40
  job()
41
+ elseif type(job) == "thread" then
42
+ task.cancel(job)
40
43
  elseif typeof(job) == "RBXScriptConnection" then
41
44
  job:Disconnect()
42
45
  elseif type(job) == "table" and type(job.Destroy) == "function" then
@@ -72,4 +75,4 @@ function MaidTaskUtils.delayed(time, job)
72
75
  end
73
76
  end
74
77
 
75
- return MaidTaskUtils
78
+ return MaidTaskUtils