@quenty/valueobject 3.4.1-canary.8533eea.0 → 3.5.1
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 +9 -1
- package/README.md +5 -3
- package/package.json +7 -7
- package/src/Shared/ValueObject.lua +31 -16
- package/src/Shared/ValueObjectUtils.lua +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,15 @@
|
|
|
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.
|
|
6
|
+
## [3.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valueobject@3.5.0...@quenty/valueobject@3.5.1) (2021-12-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/valueobject
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valueobject@3.4.0...@quenty/valueobject@3.5.0) (2021-12-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @quenty/valueobject
|
|
9
17
|
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
## ValueObject
|
|
2
2
|
<div align="center">
|
|
3
|
-
<a href="http://quenty.github.io/
|
|
4
|
-
<img src="https://
|
|
3
|
+
<a href="http://quenty.github.io/NevermoreEngine/">
|
|
4
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
|
|
5
5
|
</a>
|
|
6
6
|
<a href="https://discord.gg/mhtGUS8">
|
|
7
|
-
<img src="https://img.shields.io/
|
|
7
|
+
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
|
|
8
8
|
</a>
|
|
9
9
|
<a href="https://github.com/Quenty/NevermoreEngine/actions">
|
|
10
10
|
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
To work like value objects in Roblox and track a single item with .Changed events. The motivation here is to keep it simple to work with an encapsulated value. Instead of exposing an `IPropertyChanged` interface like C# might do, we instead expose objects with .Changed that are encapsulated within the object in question.
|
|
15
15
|
|
|
16
|
+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/ValueObject">View docs →</a></div>
|
|
17
|
+
|
|
16
18
|
## Installation
|
|
17
19
|
```
|
|
18
20
|
npm install @quenty/valueobject --save
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/valueobject",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
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.
|
|
30
|
-
"@quenty/loader": "3.1.
|
|
31
|
-
"@quenty/maid": "2.0.
|
|
32
|
-
"@quenty/rx": "3.
|
|
33
|
-
"@quenty/signal": "2.0.
|
|
29
|
+
"@quenty/brio": "^3.5.1",
|
|
30
|
+
"@quenty/loader": "^3.1.2",
|
|
31
|
+
"@quenty/maid": "^2.0.2",
|
|
32
|
+
"@quenty/rx": "^3.5.1",
|
|
33
|
+
"@quenty/signal": "^2.0.1"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "d146c77d0a8e452824de0ab0b4b03ba0370bcc1b"
|
|
39
39
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
--[=[
|
|
2
|
+
To work like value objects in Roblox and track a single item,
|
|
3
|
+
with `.Changed` events
|
|
4
|
+
@class ValueObject
|
|
5
|
+
]=]
|
|
4
6
|
|
|
5
7
|
local require = require(script.Parent.loader).load(script)
|
|
6
8
|
|
|
@@ -10,18 +12,11 @@ local Maid = require("Maid")
|
|
|
10
12
|
local ValueObject = {}
|
|
11
13
|
ValueObject.ClassName = "ValueObject"
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-- @tparam Variant newValue The new value
|
|
19
|
-
-- @tparam Variant oldValue The old value
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
--- Constructs a new value object
|
|
23
|
-
-- @constructor
|
|
24
|
-
-- @treturn ValueObject
|
|
15
|
+
--[=[
|
|
16
|
+
Constructs a new value object
|
|
17
|
+
@param baseValue T
|
|
18
|
+
@return ValueObject
|
|
19
|
+
]=]
|
|
25
20
|
function ValueObject.new(baseValue)
|
|
26
21
|
local self = {}
|
|
27
22
|
|
|
@@ -35,10 +30,26 @@ function ValueObject.new(baseValue)
|
|
|
35
30
|
return setmetatable(self, ValueObject)
|
|
36
31
|
end
|
|
37
32
|
|
|
33
|
+
--[=[
|
|
34
|
+
Returns whether the object is a ValueObject class
|
|
35
|
+
@param value any
|
|
36
|
+
@return boolean
|
|
37
|
+
]=]
|
|
38
38
|
function ValueObject.isValueObject(value)
|
|
39
39
|
return type(value) == "table" and getmetatable(value) == ValueObject
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
--[=[
|
|
43
|
+
Event fires when the value's object value change
|
|
44
|
+
@prop Changed Signal<T> -- fires with oldValue, newValue
|
|
45
|
+
@within ValueObject
|
|
46
|
+
]=]
|
|
47
|
+
|
|
48
|
+
--[=[
|
|
49
|
+
The value of the ValueObject
|
|
50
|
+
@prop Value T
|
|
51
|
+
@within ValueObject
|
|
52
|
+
]=]
|
|
42
53
|
function ValueObject:__index(index)
|
|
43
54
|
if index == "Value" then
|
|
44
55
|
return self._value
|
|
@@ -68,7 +79,11 @@ function ValueObject:__newindex(index, value)
|
|
|
68
79
|
end
|
|
69
80
|
end
|
|
70
81
|
|
|
71
|
-
|
|
82
|
+
--[=[
|
|
83
|
+
Forces the value to be nil on cleanup, cleans up the Maid
|
|
84
|
+
|
|
85
|
+
Does not fire the event since 3.5.0
|
|
86
|
+
]=]
|
|
72
87
|
function ValueObject:Destroy()
|
|
73
88
|
rawset(self, "_value", nil)
|
|
74
89
|
self._maid:DoCleaning()
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
--[=[
|
|
2
|
+
Utils that work with Roblox Value objects (and also ValueObject)
|
|
3
|
+
@class ValueObjectUtils
|
|
4
|
+
]=]
|
|
3
5
|
|
|
4
6
|
local require = require(script.Parent.loader).load(script)
|
|
5
7
|
|