@quenty/attributeutils 3.0.1 → 3.0.2-canary.214.71808c7.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,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
+ ## [3.0.2-canary.214.71808c7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/attributeutils@3.0.1...@quenty/attributeutils@3.0.2-canary.214.71808c7.0) (2021-09-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add default attribute utils ([fefc5fd](https://github.com/Quenty/NevermoreEngine/commit/fefc5fde460be1d4cf7b498e145206b204be689e))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [3.0.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/attributeutils@3.0.0...@quenty/attributeutils@3.0.1) (2021-09-18)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/attributeutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/attributeutils",
3
- "version": "3.0.1",
3
+ "version": "3.0.2-canary.214.71808c7.0",
4
4
  "description": "Provides utility functions to work with attributes in Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,12 +25,12 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/loader": "^3.0.1",
29
- "@quenty/maid": "^2.0.0",
30
- "@quenty/rx": "^3.0.1"
28
+ "@quenty/loader": "3.0.1",
29
+ "@quenty/maid": "2.0.0",
30
+ "@quenty/rx": "3.0.1"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "f1f01c538a7b1c2446134ea9490986d201a7e7b9"
35
+ "gitHead": "71808c7e3e701e63c4f24eba60e4e2eabc5e6476"
36
36
  }
@@ -9,17 +9,24 @@ local Maid = require("Maid")
9
9
 
10
10
  local RxAttributeUtils = {}
11
11
 
12
- function RxAttributeUtils.observeAttribute(instance, attributeName)
12
+ function RxAttributeUtils.observeAttribute(instance, attributeName, defaultValue)
13
13
  assert(typeof(instance) == "Instance", "Bad instance")
14
14
  assert(type(attributeName) == "string", "Bad attributeName")
15
15
 
16
16
  return Observable.new(function(sub)
17
17
  local maid = Maid.new()
18
18
 
19
- maid:GiveTask(instance:GetAttributeChangedSignal(attributeName):Connect(function()
20
- sub:Fire(instance:GetAttribute(attributeName))
21
- end))
22
- sub:Fire(instance:GetAttribute(attributeName))
19
+ local function update()
20
+ local value = instance:GetAttribute(attributeName)
21
+ if value == nil then
22
+ sub:Fire(defaultValue)
23
+ else
24
+ sub:Fire(value)
25
+ end
26
+ end
27
+
28
+ maid:GiveTask(instance:GetAttributeChangedSignal(attributeName):Connect(update))
29
+ update()
23
30
 
24
31
  return maid
25
32
  end)