@quenty/binder 14.19.3 → 14.19.4-canary.11a5dcf.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 +11 -0
- package/package.json +12 -12
- package/src/Shared/Binder.lua +3 -3
- package/src/Shared/BinderGroup.lua +21 -9
- package/src/Shared/BinderGroupProvider.lua +1 -1
- package/src/Shared/BinderProvider.lua +10 -11
- package/src/Shared/BinderProvider.spec.lua +4 -3
- package/src/Shared/BinderUtils.lua +17 -12
- package/src/Shared/Collection/BoundChildCollection.lua +32 -17
- package/src/Shared/Promise/promiseBoundClass.lua +4 -4
- package/src/Shared/Trackers/BoundAncestorTracker.lua +3 -4
- package/src/Shared/Trackers/BoundParentTracker.lua +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## [14.19.4-canary.11a5dcf.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/binder@14.19.3...@quenty/binder@14.19.4-canary.11a5dcf.0) (2025-05-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Additional type checking updates ([05ba29a](https://github.com/Quenty/NevermoreEngine/commit/05ba29a03efc9f3feed74b34f1d9dfb237496214))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [14.19.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/binder@14.19.2...@quenty/binder@14.19.3) (2025-04-10)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/binder
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/binder",
|
|
3
|
-
"version": "14.19.
|
|
3
|
+
"version": "14.19.4-canary.11a5dcf.0",
|
|
4
4
|
"description": "Utility object to Bind a class to Roblox object, and associated helper methods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/baseobject": "
|
|
29
|
-
"@quenty/brio": "
|
|
30
|
-
"@quenty/instanceutils": "
|
|
31
|
-
"@quenty/linkutils": "
|
|
32
|
-
"@quenty/loader": "
|
|
33
|
-
"@quenty/maid": "
|
|
34
|
-
"@quenty/promise": "
|
|
35
|
-
"@quenty/rx": "
|
|
36
|
-
"@quenty/signal": "
|
|
37
|
-
"@quenty/valueobject": "
|
|
28
|
+
"@quenty/baseobject": "10.8.4-canary.11a5dcf.0",
|
|
29
|
+
"@quenty/brio": "14.17.4-canary.11a5dcf.0",
|
|
30
|
+
"@quenty/instanceutils": "13.17.4-canary.11a5dcf.0",
|
|
31
|
+
"@quenty/linkutils": "13.17.4-canary.11a5dcf.0",
|
|
32
|
+
"@quenty/loader": "10.8.4-canary.11a5dcf.0",
|
|
33
|
+
"@quenty/maid": "3.4.4-canary.11a5dcf.0",
|
|
34
|
+
"@quenty/promise": "10.10.5-canary.11a5dcf.0",
|
|
35
|
+
"@quenty/rx": "13.17.4-canary.11a5dcf.0",
|
|
36
|
+
"@quenty/signal": "7.10.4-canary.11a5dcf.0",
|
|
37
|
+
"@quenty/valueobject": "13.17.4-canary.11a5dcf.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "11a5dcf7d4c7a0bfbf3337e97d30e8346ea09d3f"
|
|
43
43
|
}
|
package/src/Shared/Binder.lua
CHANGED
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
|
|
28
28
|
local require = require(script.Parent.loader).load(script)
|
|
29
29
|
|
|
30
|
-
local RunService = game:GetService("RunService")
|
|
31
30
|
local CollectionService = game:GetService("CollectionService")
|
|
31
|
+
local RunService = game:GetService("RunService")
|
|
32
32
|
|
|
33
33
|
local Brio = require("Brio")
|
|
34
|
+
local CancelToken = require("CancelToken")
|
|
34
35
|
local Maid = require("Maid")
|
|
35
36
|
local MaidTaskUtils = require("MaidTaskUtils")
|
|
36
37
|
local Observable = require("Observable")
|
|
37
38
|
local Promise = require("Promise")
|
|
38
39
|
local Signal = require("Signal")
|
|
39
|
-
local _CancelToken = require("CancelToken")
|
|
40
40
|
|
|
41
41
|
local Binder = {}
|
|
42
42
|
Binder.__index = Binder
|
|
@@ -602,7 +602,7 @@ end
|
|
|
602
602
|
@param cancelToken CancelToken?
|
|
603
603
|
@return Promise<T>
|
|
604
604
|
]=]
|
|
605
|
-
function Binder.Promise<T>(self: Binder<T>, inst: Instance, cancelToken:
|
|
605
|
+
function Binder.Promise<T>(self: Binder<T>, inst: Instance, cancelToken: CancelToken.CancelToken?): Promise.Promise<T>
|
|
606
606
|
assert(typeof(inst) == "Instance", "Argument 'inst' is not an Instance")
|
|
607
607
|
|
|
608
608
|
local class = self:Get(inst)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Groups binders together into a list, and allows binders to be dynamically
|
|
3
4
|
added or removed.
|
|
@@ -18,6 +19,17 @@ local BinderGroup = {}
|
|
|
18
19
|
BinderGroup.ClassName = "BinderGroup"
|
|
19
20
|
BinderGroup.__index = BinderGroup
|
|
20
21
|
|
|
22
|
+
export type BinderConstructorValidator = (constructor: Binder.BinderConstructor<any>) -> boolean
|
|
23
|
+
|
|
24
|
+
export type BinderGroup = typeof(setmetatable(
|
|
25
|
+
{} :: {
|
|
26
|
+
_binders: { Binder.Binder<any> },
|
|
27
|
+
_bindersByTag: { [string]: Binder.Binder<any> },
|
|
28
|
+
_validateConstructor: BinderConstructorValidator?,
|
|
29
|
+
BinderAdded: Signal.Signal<Binder.Binder<any>>,
|
|
30
|
+
},
|
|
31
|
+
{} :: typeof({ __index = BinderGroup })
|
|
32
|
+
))
|
|
21
33
|
--[=[
|
|
22
34
|
Constructs a new BinderGroup
|
|
23
35
|
|
|
@@ -25,14 +37,14 @@ BinderGroup.__index = BinderGroup
|
|
|
25
37
|
@param validateConstructor (constructor: any) -> boolean -- Validates a binder matches T
|
|
26
38
|
@return BinderGroup<T>
|
|
27
39
|
]=]
|
|
28
|
-
function BinderGroup.new(binders, validateConstructor)
|
|
29
|
-
local self = setmetatable({}, BinderGroup)
|
|
40
|
+
function BinderGroup.new(binders: { Binder.Binder<any> }, validateConstructor: BinderConstructorValidator?): BinderGroup
|
|
41
|
+
local self: BinderGroup = setmetatable({} :: any, BinderGroup)
|
|
30
42
|
|
|
31
43
|
self._binders = {}
|
|
32
44
|
self._bindersByTag = {}
|
|
33
45
|
self._validateConstructor = validateConstructor
|
|
34
46
|
|
|
35
|
-
self.BinderAdded = Signal.new()
|
|
47
|
+
self.BinderAdded = Signal.new() :: any
|
|
36
48
|
|
|
37
49
|
self:AddList(binders)
|
|
38
50
|
|
|
@@ -44,13 +56,13 @@ end
|
|
|
44
56
|
|
|
45
57
|
@param binders { Binder<T> }
|
|
46
58
|
]=]
|
|
47
|
-
function BinderGroup
|
|
59
|
+
function BinderGroup.AddList(self: BinderGroup, binders: { Binder.Binder<any> })
|
|
48
60
|
assert(type(binders) == "table", "Bad binders")
|
|
49
61
|
|
|
50
62
|
-- Assume to be using osyris's typechecking library,
|
|
51
63
|
-- we have an optional constructor to validate binder classes.
|
|
52
64
|
for _, binder in binders do
|
|
53
|
-
self:Add(binder)
|
|
65
|
+
self:Add(binder :: any)
|
|
54
66
|
end
|
|
55
67
|
end
|
|
56
68
|
|
|
@@ -59,7 +71,7 @@ end
|
|
|
59
71
|
|
|
60
72
|
@param binder Binder<T>
|
|
61
73
|
]=]
|
|
62
|
-
function BinderGroup
|
|
74
|
+
function BinderGroup.Add(self: BinderGroup, binder: Binder.Binder<any>)
|
|
63
75
|
assert(Binder.isBinder(binder), "Binder is not a binder")
|
|
64
76
|
|
|
65
77
|
if self._validateConstructor then
|
|
@@ -84,12 +96,12 @@ end
|
|
|
84
96
|
Do not modify the list of binders returned here
|
|
85
97
|
:::
|
|
86
98
|
|
|
87
|
-
@return {
|
|
99
|
+
@return { Binder.Binder<any> }
|
|
88
100
|
]=]
|
|
89
|
-
function BinderGroup
|
|
101
|
+
function BinderGroup.GetBinders(self: BinderGroup): { Binder.Binder<any> }
|
|
90
102
|
assert(self._binders, "No self._binders")
|
|
91
103
|
|
|
92
104
|
return self._binders
|
|
93
105
|
end
|
|
94
106
|
|
|
95
|
-
return BinderGroup
|
|
107
|
+
return BinderGroup
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
local require = require(script.Parent.loader).load(script)
|
|
7
7
|
|
|
8
|
-
local Promise = require("Promise")
|
|
9
8
|
local Maid = require("Maid")
|
|
9
|
+
local Promise = require("Promise")
|
|
10
10
|
|
|
11
11
|
local BinderProvider = {}
|
|
12
12
|
BinderProvider.ClassName = "BinderProvider"
|
|
@@ -90,15 +90,14 @@ function BinderProvider:PromiseBinder(binderName)
|
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
return self._bindersAddedPromise
|
|
94
|
-
:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
end)
|
|
93
|
+
return self._bindersAddedPromise:Then(function()
|
|
94
|
+
local binder = self:Get(binderName)
|
|
95
|
+
if binder then
|
|
96
|
+
return binder
|
|
97
|
+
else
|
|
98
|
+
return Promise.rejected()
|
|
99
|
+
end
|
|
100
|
+
end)
|
|
102
101
|
end
|
|
103
102
|
|
|
104
103
|
--[=[
|
|
@@ -209,4 +208,4 @@ function BinderProvider:Destroy()
|
|
|
209
208
|
self._binders = nil
|
|
210
209
|
end
|
|
211
210
|
|
|
212
|
-
return BinderProvider
|
|
211
|
+
return BinderProvider
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
@class BinderProvider.spec.lua
|
|
3
3
|
]]
|
|
4
4
|
|
|
5
|
-
local require =
|
|
5
|
+
local require =
|
|
6
|
+
require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
7
|
|
|
7
8
|
local Binder = require("Binder")
|
|
8
9
|
local BinderProvider = require("BinderProvider")
|
|
@@ -22,7 +23,7 @@ describe("BinderProvider.new()", function()
|
|
|
22
23
|
assert(arg == 12345, "Bad arg")
|
|
23
24
|
|
|
24
25
|
self:Add(Binder.new("Test", function()
|
|
25
|
-
return { Destroy = function() end
|
|
26
|
+
return { Destroy = function() end }
|
|
26
27
|
end))
|
|
27
28
|
end)
|
|
28
29
|
|
|
@@ -42,4 +43,4 @@ describe("BinderProvider.new()", function()
|
|
|
42
43
|
if provider then
|
|
43
44
|
provider:Destroy()
|
|
44
45
|
end
|
|
45
|
-
end)
|
|
46
|
+
end)
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Utility methods for the binder object.
|
|
3
4
|
@class BinderUtils
|
|
4
5
|
]=]
|
|
5
6
|
|
|
7
|
+
local require = require(script.Parent.loader).load(script)
|
|
8
|
+
|
|
6
9
|
local CollectionService = game:GetService("CollectionService")
|
|
7
10
|
|
|
11
|
+
local Binder = require("Binder")
|
|
12
|
+
|
|
8
13
|
local BinderUtils = {}
|
|
9
14
|
|
|
10
15
|
--[=[
|
|
@@ -15,7 +20,7 @@ local BinderUtils = {}
|
|
|
15
20
|
@param child Instance
|
|
16
21
|
@return T?
|
|
17
22
|
]=]
|
|
18
|
-
function BinderUtils.findFirstAncestor(binder
|
|
23
|
+
function BinderUtils.findFirstAncestor<T>(binder: Binder.Binder<T>, child: Instance): T?
|
|
19
24
|
assert(type(binder) == "table", "Binder must be binder")
|
|
20
25
|
assert(typeof(child) == "Instance", "Child parameter must be instance")
|
|
21
26
|
|
|
@@ -38,7 +43,7 @@ end
|
|
|
38
43
|
@param parent Instance
|
|
39
44
|
@return T?
|
|
40
45
|
]=]
|
|
41
|
-
function BinderUtils.findFirstChild(binder
|
|
46
|
+
function BinderUtils.findFirstChild<T>(binder: Binder.Binder<T>, parent: Instance): T?
|
|
42
47
|
assert(type(binder) == "table", "Binder must be binder")
|
|
43
48
|
assert(typeof(parent) == "Instance", "Parent parameter must be instance")
|
|
44
49
|
|
|
@@ -59,7 +64,7 @@ end
|
|
|
59
64
|
@param parent Instance
|
|
60
65
|
@return {T}
|
|
61
66
|
]=]
|
|
62
|
-
function BinderUtils.getChildren(binder
|
|
67
|
+
function BinderUtils.getChildren<T>(binder: Binder.Binder<T>, parent: Instance): { T }
|
|
63
68
|
assert(type(binder) == "table", "Binder must be binder")
|
|
64
69
|
assert(typeof(parent) == "Instance", "Parent parameter must be instance")
|
|
65
70
|
|
|
@@ -82,13 +87,14 @@ end
|
|
|
82
87
|
@param bindersList { Binder<any> }
|
|
83
88
|
@return { [string]: Binder<any> }
|
|
84
89
|
]=]
|
|
85
|
-
function BinderUtils.mapBinderListToTable(bindersList)
|
|
90
|
+
function BinderUtils.mapBinderListToTable<T>(bindersList: { Binder.Binder<T> }): { [string]: Binder.Binder<T> }
|
|
86
91
|
assert(type(bindersList) == "table", "bindersList must be a table of binders")
|
|
87
92
|
|
|
88
|
-
local tags = {}
|
|
93
|
+
local tags: { [string]: Binder.Binder<T> } = {}
|
|
89
94
|
for _, binder in bindersList do
|
|
90
|
-
tags[binder:GetTag()] = binder
|
|
95
|
+
tags[(binder :: any):GetTag()] = binder :: any
|
|
91
96
|
end
|
|
97
|
+
|
|
92
98
|
return tags
|
|
93
99
|
end
|
|
94
100
|
|
|
@@ -105,7 +111,7 @@ end
|
|
|
105
111
|
@param instanceList { Instance }
|
|
106
112
|
@return { T }
|
|
107
113
|
]=]
|
|
108
|
-
function BinderUtils.getMappedFromList(tagsMap, instanceList)
|
|
114
|
+
function BinderUtils.getMappedFromList<T>(tagsMap: { [string]: Binder.Binder<T> }, instanceList: { Instance }): { T }
|
|
109
115
|
local objects = {}
|
|
110
116
|
|
|
111
117
|
for _, instance in instanceList do
|
|
@@ -130,7 +136,7 @@ end
|
|
|
130
136
|
@param parent Instance
|
|
131
137
|
@return { T }
|
|
132
138
|
]=]
|
|
133
|
-
function BinderUtils.getChildrenOfBinders(bindersList, parent)
|
|
139
|
+
function BinderUtils.getChildrenOfBinders<T>(bindersList: { Binder.Binder<T> }, parent: Instance): { T }
|
|
134
140
|
assert(type(bindersList) == "table", "bindersList must be a table of binders")
|
|
135
141
|
assert(typeof(parent) == "Instance", "Parent parameter must be instance")
|
|
136
142
|
|
|
@@ -146,7 +152,7 @@ end
|
|
|
146
152
|
@param parent Instance
|
|
147
153
|
@return {T}
|
|
148
154
|
]=]
|
|
149
|
-
function BinderUtils.getLinkedChildren(binder
|
|
155
|
+
function BinderUtils.getLinkedChildren<T>(binder: Binder.Binder<T>, linkName: string, parent: Instance): { T }
|
|
150
156
|
local seen = {}
|
|
151
157
|
local objects = {}
|
|
152
158
|
for _, item in parent:GetChildren() do
|
|
@@ -177,7 +183,7 @@ end
|
|
|
177
183
|
@param parent Instance
|
|
178
184
|
@return {T}
|
|
179
185
|
]=]
|
|
180
|
-
function BinderUtils.getDescendants(binder
|
|
186
|
+
function BinderUtils.getDescendants<T>(binder: Binder.Binder<T>, parent: Instance): { T }
|
|
181
187
|
assert(type(binder) == "table", "Binder must be binder")
|
|
182
188
|
assert(typeof(parent) == "Instance", "Parent parameter must be instance")
|
|
183
189
|
|
|
@@ -191,5 +197,4 @@ function BinderUtils.getDescendants(binder, parent)
|
|
|
191
197
|
return objects
|
|
192
198
|
end
|
|
193
199
|
|
|
194
|
-
|
|
195
|
-
return BinderUtils
|
|
200
|
+
return BinderUtils
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Tracks child of type of a binder.
|
|
3
4
|
@class BoundChildCollection
|
|
@@ -6,37 +7,51 @@
|
|
|
6
7
|
local require = require(script.Parent.loader).load(script)
|
|
7
8
|
|
|
8
9
|
local BaseObject = require("BaseObject")
|
|
10
|
+
local Binder = require("Binder")
|
|
11
|
+
local Set = require("Set")
|
|
9
12
|
local Signal = require("Signal")
|
|
10
13
|
|
|
11
14
|
local BoundChildCollection = setmetatable({}, BaseObject)
|
|
12
15
|
BoundChildCollection.ClassName = "BoundChildCollection"
|
|
13
16
|
BoundChildCollection.__index = BoundChildCollection
|
|
14
17
|
|
|
18
|
+
export type BoundChildCollection<T> = typeof(setmetatable(
|
|
19
|
+
{} :: {
|
|
20
|
+
_binder: Binder.Binder<T>,
|
|
21
|
+
_parent: Instance,
|
|
22
|
+
_classes: Set.Set<T>,
|
|
23
|
+
ClassAdded: Signal.Signal<T>,
|
|
24
|
+
ClassRemoved: Signal.Signal<T>,
|
|
25
|
+
_size: number,
|
|
26
|
+
},
|
|
27
|
+
{} :: typeof({ __index = BoundChildCollection })
|
|
28
|
+
)) & BaseObject.BaseObject
|
|
29
|
+
|
|
15
30
|
--[=[
|
|
16
31
|
Constructcs a new BoundChildCollection.
|
|
17
32
|
@param binder Binder<T>
|
|
18
33
|
@param parent Instance
|
|
19
34
|
@return BoundChildCollection<T>
|
|
20
35
|
]=]
|
|
21
|
-
function BoundChildCollection.new(binder
|
|
22
|
-
local self = setmetatable(BaseObject.new(), BoundChildCollection)
|
|
36
|
+
function BoundChildCollection.new<T>(binder: Binder.Binder<T>, parent: Instance): BoundChildCollection<T>
|
|
37
|
+
local self: BoundChildCollection<T> = setmetatable(BaseObject.new() :: any, BoundChildCollection)
|
|
23
38
|
|
|
24
39
|
self._binder = binder or error("No binder")
|
|
25
40
|
self._parent = parent or error("No parent")
|
|
26
41
|
|
|
27
|
-
--[=[
|
|
42
|
+
--[=[
|
|
28
43
|
Fires on class addition
|
|
29
44
|
@prop ClassAdded Signal<T>
|
|
30
45
|
@within BoundChildCollection
|
|
31
46
|
]=]
|
|
32
|
-
self.ClassAdded = self._maid:Add(Signal.new()) -- :Fire(class)
|
|
47
|
+
self.ClassAdded = self._maid:Add(Signal.new() :: any) -- :Fire(class)
|
|
33
48
|
|
|
34
|
-
--[=[
|
|
49
|
+
--[=[
|
|
35
50
|
Fires on class removal
|
|
36
51
|
@prop ClassRemoved Signal<T>
|
|
37
52
|
@within BoundChildCollection
|
|
38
53
|
]=]
|
|
39
|
-
self.ClassRemoved = self._maid:Add(Signal.new()) -- :Fire(class)
|
|
54
|
+
self.ClassRemoved = self._maid:Add(Signal.new() :: any) -- :Fire(class)
|
|
40
55
|
|
|
41
56
|
self._classes = {} -- [class] = true
|
|
42
57
|
self._size = 0
|
|
@@ -58,7 +73,7 @@ end
|
|
|
58
73
|
@param class T
|
|
59
74
|
@return boolean? -- true if the class exists, nil otherwise
|
|
60
75
|
]=]
|
|
61
|
-
function BoundChildCollection
|
|
76
|
+
function BoundChildCollection.HasClass<T>(self: BoundChildCollection<T>, class: T): boolean
|
|
62
77
|
return self._classes[class]
|
|
63
78
|
end
|
|
64
79
|
|
|
@@ -66,7 +81,7 @@ end
|
|
|
66
81
|
Gets the size
|
|
67
82
|
@return number
|
|
68
83
|
]=]
|
|
69
|
-
function BoundChildCollection
|
|
84
|
+
function BoundChildCollection.GetSize<T>(self: BoundChildCollection<T>): number
|
|
70
85
|
return self._size
|
|
71
86
|
end
|
|
72
87
|
|
|
@@ -79,7 +94,7 @@ end
|
|
|
79
94
|
|
|
80
95
|
@return { [T] = true } -- The set
|
|
81
96
|
]=]
|
|
82
|
-
function BoundChildCollection
|
|
97
|
+
function BoundChildCollection.GetSet<T>(self: BoundChildCollection<T>): Set.Set<T>
|
|
83
98
|
return self._classes
|
|
84
99
|
end
|
|
85
100
|
|
|
@@ -87,7 +102,7 @@ end
|
|
|
87
102
|
Slow than :GetSet(), but adds them in an ordered list
|
|
88
103
|
@return { T }
|
|
89
104
|
]=]
|
|
90
|
-
function BoundChildCollection
|
|
105
|
+
function BoundChildCollection.GetClasses<T>(self: BoundChildCollection<T>): { T }
|
|
91
106
|
local list = {}
|
|
92
107
|
for class, _ in self._classes do
|
|
93
108
|
table.insert(list, class)
|
|
@@ -95,7 +110,7 @@ function BoundChildCollection:GetClasses()
|
|
|
95
110
|
return list
|
|
96
111
|
end
|
|
97
112
|
|
|
98
|
-
function BoundChildCollection
|
|
113
|
+
function BoundChildCollection._startTracking<T>(self: BoundChildCollection<T>)
|
|
99
114
|
self._maid:GiveTask(self._parent.ChildAdded:Connect(function(child)
|
|
100
115
|
self:_addChild(child)
|
|
101
116
|
end))
|
|
@@ -110,7 +125,7 @@ function BoundChildCollection:_startTracking()
|
|
|
110
125
|
end
|
|
111
126
|
end
|
|
112
127
|
|
|
113
|
-
function BoundChildCollection
|
|
128
|
+
function BoundChildCollection._addChild<T>(self: BoundChildCollection<T>, inst: Instance, doNotFire: boolean?): ()
|
|
114
129
|
local class = self._binder:Get(inst)
|
|
115
130
|
if not class then
|
|
116
131
|
return
|
|
@@ -119,7 +134,7 @@ function BoundChildCollection:_addChild(inst, doNotFire)
|
|
|
119
134
|
self:_addClass(class, doNotFire)
|
|
120
135
|
end
|
|
121
136
|
|
|
122
|
-
function BoundChildCollection
|
|
137
|
+
function BoundChildCollection._handleNewClassBound<T>(self: BoundChildCollection<T>, class: T, inst: Instance): ()
|
|
123
138
|
if inst.Parent ~= self._parent then
|
|
124
139
|
return
|
|
125
140
|
end
|
|
@@ -127,7 +142,7 @@ function BoundChildCollection:_handleNewClassBound(class, inst)
|
|
|
127
142
|
self:_addClass(class)
|
|
128
143
|
end
|
|
129
144
|
|
|
130
|
-
function BoundChildCollection
|
|
145
|
+
function BoundChildCollection._removeChild<T>(self: BoundChildCollection<T>, inst: Instance): ()
|
|
131
146
|
local class = self._binder:Get(inst)
|
|
132
147
|
if not class then
|
|
133
148
|
return
|
|
@@ -136,7 +151,7 @@ function BoundChildCollection:_removeChild(inst)
|
|
|
136
151
|
self:_removeClass(class)
|
|
137
152
|
end
|
|
138
153
|
|
|
139
|
-
function BoundChildCollection
|
|
154
|
+
function BoundChildCollection._addClass<T>(self: BoundChildCollection<T>, class: T, doNotFire: boolean?): ()
|
|
140
155
|
if self._classes[class] then
|
|
141
156
|
return
|
|
142
157
|
end
|
|
@@ -148,7 +163,7 @@ function BoundChildCollection:_addClass(class, doNotFire)
|
|
|
148
163
|
end
|
|
149
164
|
end
|
|
150
165
|
|
|
151
|
-
function BoundChildCollection
|
|
166
|
+
function BoundChildCollection._removeClass<T>(self: BoundChildCollection<T>, class: T): ()
|
|
152
167
|
if not self._classes[class] then
|
|
153
168
|
return
|
|
154
169
|
end
|
|
@@ -158,4 +173,4 @@ function BoundChildCollection:_removeClass(class)
|
|
|
158
173
|
self.ClassRemoved:Fire(class)
|
|
159
174
|
end
|
|
160
175
|
|
|
161
|
-
return BoundChildCollection
|
|
176
|
+
return BoundChildCollection
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
9
|
local Binder = require("Binder")
|
|
10
|
-
local
|
|
11
|
-
local
|
|
10
|
+
local CancelToken = require("CancelToken")
|
|
11
|
+
local Promise = require("Promise")
|
|
12
12
|
|
|
13
13
|
--[=[
|
|
14
14
|
Returns a promise that resolves when the class is bound to the instance.
|
|
@@ -19,9 +19,9 @@ local _CancelToken = require("CancelToken")
|
|
|
19
19
|
@function promiseBoundClass
|
|
20
20
|
@within promiseBoundClass
|
|
21
21
|
]=]
|
|
22
|
-
return function<T>(binder: Binder.Binder<T>, inst: Instance, cancelToken:
|
|
22
|
+
return function<T>(binder: Binder.Binder<T>, inst: Instance, cancelToken: CancelToken.CancelToken?): Promise.Promise<T>
|
|
23
23
|
assert(Binder.isBinder(binder), "'binder' must be table")
|
|
24
24
|
assert(typeof(inst) == "Instance", "'inst' must be instance")
|
|
25
25
|
|
|
26
26
|
return binder:Promise(inst, cancelToken)
|
|
27
|
-
end
|
|
27
|
+
end
|
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
local require = require(script.Parent.loader).load(script)
|
|
7
7
|
|
|
8
8
|
local BaseObject = require("BaseObject")
|
|
9
|
-
local ValueObject = require("ValueObject")
|
|
10
9
|
local BinderUtils = require("BinderUtils")
|
|
10
|
+
local ValueObject = require("ValueObject")
|
|
11
11
|
|
|
12
12
|
local BoundAncestorTracker = setmetatable({}, BaseObject)
|
|
13
13
|
BoundAncestorTracker.ClassName = "BoundAncestorTracker"
|
|
14
14
|
BoundAncestorTracker.__index = BoundAncestorTracker
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
--[=[
|
|
18
17
|
Constructs a new BoundAncestorTracker
|
|
19
18
|
|
|
@@ -27,7 +26,7 @@ function BoundAncestorTracker.new(binder, child)
|
|
|
27
26
|
self._child = child or error("No child")
|
|
28
27
|
self._binder = binder or error("No binder")
|
|
29
28
|
|
|
30
|
-
--[=[
|
|
29
|
+
--[=[
|
|
31
30
|
@prop Class ValueObject<T>
|
|
32
31
|
@readonly
|
|
33
32
|
@within BoundAncestorTracker
|
|
@@ -68,4 +67,4 @@ function BoundAncestorTracker:_update()
|
|
|
68
67
|
self.Class.Value = BinderUtils.findFirstAncestor(self._binder, parent)
|
|
69
68
|
end
|
|
70
69
|
|
|
71
|
-
return BoundAncestorTracker
|
|
70
|
+
return BoundAncestorTracker
|