@quenty/valueobject 3.2.0 → 3.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,28 @@
|
|
|
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
|
+
# [3.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valueobject@3.3.0...@quenty/valueobject@3.4.0) (2021-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* ValueObject does not fire .Changed on cleanup. ([ffd1a82](https://github.com/Quenty/NevermoreEngine/commit/ffd1a82e9db55891672a439285731dbf99d19ad1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valueobject@3.2.0...@quenty/valueobject@3.3.0) (2021-11-20)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* Support MacOS syncing ([#225](https://github.com/Quenty/NevermoreEngine/issues/225)) ([03f9183](https://github.com/Quenty/NevermoreEngine/commit/03f918392c6a5bdd33f8a17c38de371d1e06c67a))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [3.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valueobject@3.1.2...@quenty/valueobject@3.2.0) (2021-10-30)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @quenty/valueobject
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/valueobject",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "To work like value objects in Roblox and track a single item with .Changed events",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/brio": "^3.
|
|
29
|
+
"@quenty/brio": "^3.4.0",
|
|
30
30
|
"@quenty/loader": "^3.1.1",
|
|
31
31
|
"@quenty/maid": "^2.0.1",
|
|
32
|
-
"@quenty/rx": "^3.
|
|
32
|
+
"@quenty/rx": "^3.4.0",
|
|
33
33
|
"@quenty/signal": "^2.0.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "8a33939501e25cf227e96f7eb0d1a23b86f10f3c"
|
|
39
39
|
}
|
|
@@ -35,6 +35,10 @@ function ValueObject.new(baseValue)
|
|
|
35
35
|
return setmetatable(self, ValueObject)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
function ValueObject.isValueObject(value)
|
|
39
|
+
return type(value) == "table" and getmetatable(value) == ValueObject
|
|
40
|
+
end
|
|
41
|
+
|
|
38
42
|
function ValueObject:__index(index)
|
|
39
43
|
if index == "Value" then
|
|
40
44
|
return self._value
|
|
@@ -54,8 +58,10 @@ function ValueObject:__newindex(index, value)
|
|
|
54
58
|
rawset(self, "_value", value)
|
|
55
59
|
|
|
56
60
|
local maid = Maid.new()
|
|
57
|
-
|
|
61
|
+
|
|
58
62
|
self.Changed:Fire(value, previous, maid)
|
|
63
|
+
|
|
64
|
+
self._maid._valueMaid = maid
|
|
59
65
|
end
|
|
60
66
|
else
|
|
61
67
|
error(("%q is not a member of ValueObject"):format(tostring(index)))
|
|
@@ -64,8 +70,9 @@ end
|
|
|
64
70
|
|
|
65
71
|
--- Forces the value to be nil on cleanup, cleans up the Maid
|
|
66
72
|
function ValueObject:Destroy()
|
|
67
|
-
self
|
|
73
|
+
rawset(self, "_value", nil)
|
|
68
74
|
self._maid:DoCleaning()
|
|
75
|
+
setmetatable(self, nil)
|
|
69
76
|
end
|
|
70
77
|
|
|
71
78
|
return ValueObject
|
|
@@ -6,6 +6,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
6
6
|
local Maid = require("Maid")
|
|
7
7
|
local Brio = require("Brio")
|
|
8
8
|
local Observable = require("Observable")
|
|
9
|
+
local ValueObject = require("ValueObject")
|
|
9
10
|
|
|
10
11
|
local ValueObjectUtils = {}
|
|
11
12
|
|
|
@@ -21,9 +22,15 @@ function ValueObjectUtils.syncValue(from, to)
|
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
function ValueObjectUtils.observeValue(valueObject)
|
|
24
|
-
assert(valueObject, "Bad valueObject")
|
|
25
|
+
assert(ValueObject.isValueObject(valueObject), "Bad valueObject")
|
|
25
26
|
|
|
26
27
|
return Observable.new(function(sub)
|
|
28
|
+
if not valueObject.Destroy then
|
|
29
|
+
warn("[ValueObjectUtils.observeValue] - Connecting to dead ValueObject")
|
|
30
|
+
-- No firing, we're dead
|
|
31
|
+
return
|
|
32
|
+
end
|
|
33
|
+
|
|
27
34
|
local maid = Maid.new()
|
|
28
35
|
|
|
29
36
|
maid:GiveTask(valueObject.Changed:Connect(function()
|