@quenty/valuebaseutils 8.0.0-canary.331.7eefa75.0 → 8.0.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 +153 -1
- package/LICENSE.md +1 -1
- package/package.json +7 -6
- package/src/Shared/RxValueBaseUtils.lua +21 -18
- package/src/Shared/ValueBaseValue.lua +70 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,159 @@
|
|
|
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
|
-
# [8.0.0
|
|
6
|
+
# [8.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.22.0...@quenty/valuebaseutils@8.0.0) (2023-10-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* fix!: Make RxSignal not automatically skip first input ([6fe7586](https://github.com/Quenty/NevermoreEngine/commit/6fe7586029ea4753b1de7a8633c7d5af15bab420))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* RxSignal used to export a different value
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# [7.22.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.21.0...@quenty/valuebaseutils@7.22.0) (2023-09-21)
|
|
21
|
+
|
|
22
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [7.21.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.20.0...@quenty/valuebaseutils@7.21.0) (2023-09-04)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [7.20.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.19.0...@quenty/valuebaseutils@7.20.0) (2023-08-23)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# [7.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.18.0...@quenty/valuebaseutils@7.19.0) (2023-08-01)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Features
|
|
48
|
+
|
|
49
|
+
* Add predicate to ObserveBrio of ValueBaseValue ([146d9da](https://github.com/Quenty/NevermoreEngine/commit/146d9da3d6df06188e08e5768d279b72daffd336))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# [7.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.17.0...@quenty/valuebaseutils@7.18.0) (2023-07-28)
|
|
56
|
+
|
|
57
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# [7.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.16.0...@quenty/valuebaseutils@7.17.0) (2023-07-15)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* Support .Changed event o the ValueBaseValue ([641af67](https://github.com/Quenty/NevermoreEngine/commit/641af67239738f4d71f82f5f8d5e558f1b836b79))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# [7.16.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.15.0...@quenty/valuebaseutils@7.16.0) (2023-07-10)
|
|
75
|
+
|
|
76
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# [7.15.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.14.0...@quenty/valuebaseutils@7.15.0) (2023-06-17)
|
|
83
|
+
|
|
84
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# [7.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.13.0...@quenty/valuebaseutils@7.14.0) (2023-05-26)
|
|
91
|
+
|
|
92
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# [7.13.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.12.0...@quenty/valuebaseutils@7.13.0) (2023-05-08)
|
|
99
|
+
|
|
100
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# [7.12.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.11.1...@quenty/valuebaseutils@7.12.0) (2023-04-10)
|
|
107
|
+
|
|
108
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## [7.11.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.11.0...@quenty/valuebaseutils@7.11.1) (2023-04-07)
|
|
115
|
+
|
|
116
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# [7.11.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.10.0...@quenty/valuebaseutils@7.11.0) (2023-04-06)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
### Features
|
|
126
|
+
|
|
127
|
+
* Add RxValueBaseUtils.observe(parent, className, name, defaultValue) ([173d598](https://github.com/Quenty/NevermoreEngine/commit/173d59877d82d4d12740937a2aa333b3659ab1d3))
|
|
128
|
+
* Add ValueBaseValue for single-value API interface ([8bfa878](https://github.com/Quenty/NevermoreEngine/commit/8bfa878565611f68f489a528485a459cb1c0339e))
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# [7.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.9.0...@quenty/valuebaseutils@7.10.0) (2023-04-03)
|
|
135
|
+
|
|
136
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# [7.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.8.0...@quenty/valuebaseutils@7.9.0) (2023-03-31)
|
|
143
|
+
|
|
144
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# [7.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.7.0...@quenty/valuebaseutils@7.8.0) (2023-03-05)
|
|
151
|
+
|
|
152
|
+
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# [7.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@7.6.0...@quenty/valuebaseutils@7.7.0) (2023-02-27)
|
|
7
159
|
|
|
8
160
|
**Note:** Version bump only for package @quenty/valuebaseutils
|
|
9
161
|
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/valuebaseutils",
|
|
3
|
-
"version": "8.0.0
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Provides utilities for working with valuesbase objects, like IntValue or ObjectValue in Roblox.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/brio": "9.0.0
|
|
29
|
-
"@quenty/instanceutils": "8.0.0
|
|
30
|
-
"@quenty/loader": "
|
|
31
|
-
"@quenty/promise": "7.0.0
|
|
28
|
+
"@quenty/brio": "^9.0.0",
|
|
29
|
+
"@quenty/instanceutils": "^8.0.0",
|
|
30
|
+
"@quenty/loader": "^7.0.0",
|
|
31
|
+
"@quenty/promise": "^7.0.0",
|
|
32
|
+
"@quenty/rxsignal": "^2.0.0"
|
|
32
33
|
},
|
|
33
34
|
"publishConfig": {
|
|
34
35
|
"access": "public"
|
|
35
36
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "fdeae46099587019ec5fc15317dc673aed379400"
|
|
37
38
|
}
|
|
@@ -10,43 +10,46 @@ local RxBrioUtils = require("RxBrioUtils")
|
|
|
10
10
|
local RxValueBaseUtils = {}
|
|
11
11
|
|
|
12
12
|
--[=[
|
|
13
|
-
|
|
14
|
-
This caches the last value seen, and may memory leak.
|
|
15
|
-
:::
|
|
13
|
+
Observes a value base underneath a parent (last named child).
|
|
16
14
|
|
|
17
15
|
@param parent Instance
|
|
18
16
|
@param className string
|
|
19
17
|
@param name string
|
|
20
|
-
@
|
|
21
|
-
|
|
18
|
+
@param predicate callback -- Optional callback
|
|
19
|
+
@return Observable<Brio<any>>
|
|
22
20
|
]=]
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
function RxValueBaseUtils.observeBrio(parent, className, name, predicate)
|
|
22
|
+
assert(typeof(parent) == "Instance", "Bad parent")
|
|
23
|
+
assert(type(className) == "string", "Bad className")
|
|
24
|
+
assert(type(name) == "string", "Bad naem")
|
|
26
25
|
|
|
27
26
|
return RxInstanceUtils.observeLastNamedChildBrio(parent, className, name)
|
|
28
27
|
:Pipe({
|
|
29
|
-
RxBrioUtils.
|
|
28
|
+
RxBrioUtils.switchMapBrio(function(valueObject)
|
|
30
29
|
return RxValueBaseUtils.observeValue(valueObject)
|
|
31
|
-
end)
|
|
30
|
+
end),
|
|
31
|
+
RxBrioUtils.onlyLastBrioSurvives(),
|
|
32
|
+
predicate and RxBrioUtils.where(predicate) or nil;
|
|
32
33
|
})
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
--[=[
|
|
36
|
-
Observes a value base underneath a parent
|
|
37
|
+
Observes a value base underneath a parent
|
|
37
38
|
|
|
38
39
|
@param parent Instance
|
|
39
40
|
@param className string
|
|
40
41
|
@param name string
|
|
41
|
-
@
|
|
42
|
+
@param defaultValue any
|
|
43
|
+
@return Observable<any>
|
|
42
44
|
]=]
|
|
43
|
-
function RxValueBaseUtils.
|
|
44
|
-
|
|
45
|
+
function RxValueBaseUtils.observe(parent, className, name, defaultValue)
|
|
46
|
+
assert(typeof(parent) == "Instance", "Bad parent")
|
|
47
|
+
assert(type(className) == "string", "Bad className")
|
|
48
|
+
assert(type(name) == "string", "Bad name")
|
|
49
|
+
|
|
50
|
+
return RxValueBaseUtils.observeBrio(parent, className, name)
|
|
45
51
|
:Pipe({
|
|
46
|
-
RxBrioUtils.
|
|
47
|
-
return RxValueBaseUtils.observeValue(valueObject)
|
|
48
|
-
end),
|
|
49
|
-
RxBrioUtils.onlyLastBrioSurvives(),
|
|
52
|
+
RxBrioUtils.emitOnDeath(defaultValue)
|
|
50
53
|
})
|
|
51
54
|
end
|
|
52
55
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
For when attributes don't work
|
|
3
|
+
|
|
4
|
+
@class ValueBaseValue
|
|
5
|
+
]=]
|
|
6
|
+
|
|
7
|
+
local require = require(script.Parent.loader).load(script)
|
|
8
|
+
|
|
9
|
+
local RunService = game:GetService("RunService")
|
|
10
|
+
|
|
11
|
+
local ValueBaseUtils = require("ValueBaseUtils")
|
|
12
|
+
local RxValueBaseUtils = require("RxValueBaseUtils")
|
|
13
|
+
local RxSignal = require("RxSignal")
|
|
14
|
+
local Rx = require("Rx")
|
|
15
|
+
|
|
16
|
+
local ValueBaseValue = {}
|
|
17
|
+
ValueBaseValue.ClassName = "ValueBaseValue"
|
|
18
|
+
ValueBaseValue.__index = ValueBaseValue
|
|
19
|
+
|
|
20
|
+
function ValueBaseValue.new(parent, className, name, defaultValue)
|
|
21
|
+
assert(typeof(parent) == "Instance", "Bad argument 'parent'")
|
|
22
|
+
assert(type(className) == "string", "Bad argument 'className'")
|
|
23
|
+
assert(type(name) == "string", "Bad argument 'name'")
|
|
24
|
+
|
|
25
|
+
local self = {}
|
|
26
|
+
|
|
27
|
+
self._parent = parent
|
|
28
|
+
self._name = name
|
|
29
|
+
self._className = className
|
|
30
|
+
self._defaultValue = defaultValue
|
|
31
|
+
|
|
32
|
+
-- Initialize on the server
|
|
33
|
+
if RunService:IsServer() then
|
|
34
|
+
ValueBaseUtils.getOrCreateValue(parent, self._className, self._name, self._defaultValue)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
return setmetatable(self, ValueBaseValue)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
function ValueBaseValue:ObserveBrio(predicate)
|
|
41
|
+
return RxValueBaseUtils.observeBrio(self._parent, self._className, self._name, predicate)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
function ValueBaseValue:Observe()
|
|
45
|
+
return RxValueBaseUtils.observe(self._parent, self._className, self._name, self._defaultValue)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
function ValueBaseValue:__index(index)
|
|
49
|
+
if index == "Value" then
|
|
50
|
+
return ValueBaseUtils.getValue(self._parent, self._className, self._name, self._defaultValue)
|
|
51
|
+
elseif index == "Changed" then
|
|
52
|
+
return RxSignal.new(self:Observe():Pipe({
|
|
53
|
+
Rx.skip(1)
|
|
54
|
+
}))
|
|
55
|
+
elseif ValueBaseValue[index] or index == "_defaultValue" then
|
|
56
|
+
return ValueBaseValue[index]
|
|
57
|
+
else
|
|
58
|
+
error(("%q is not a member of ValueBaseValue"):format(tostring(index)))
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
function ValueBaseValue:__newindex(index, value)
|
|
63
|
+
if index == "Value" then
|
|
64
|
+
ValueBaseUtils.setValue(self._parent, self._className, self._name, value)
|
|
65
|
+
else
|
|
66
|
+
error(("%q is not a member of ValueBaseValue"):format(tostring(index)))
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
return ValueBaseValue
|