@quenty/instanceutils 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 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.4.1-canary.8533eea.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/instanceutils@3.4.0...@quenty/instanceutils@3.4.1-canary.8533eea.0) (2021-12-18)
6
+ ## [3.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/instanceutils@3.5.0...@quenty/instanceutils@3.5.1) (2021-12-30)
7
+
8
+ **Note:** Version bump only for package @quenty/instanceutils
9
+
10
+
11
+
12
+
13
+
14
+ # [3.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/instanceutils@3.4.0...@quenty/instanceutils@3.5.0) (2021-12-18)
7
15
 
8
16
  **Note:** Version bump only for package @quenty/instanceutils
9
17
 
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ## InstanceUtils
2
2
  <div align="center">
3
- <a href="http://quenty.github.io/api/">
4
- <img src="https://img.shields.io/badge/docs-website-green.svg" alt="Documentation" />
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/badge/discord-nevermore-blue.svg" alt="Discord" />
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,24 +13,9 @@
13
13
 
14
14
  Utility functions involving instances in Roblox
15
15
 
16
+ <div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/RxInstanceUtils">View docs →</a></div>
17
+
16
18
  ## Installation
17
19
  ```
18
20
  npm install @quenty/instanceutils --save
19
- ```
20
-
21
- ## API
22
-
23
- ### `RxInstanceUtils.observeProperty(instance, property)`
24
-
25
- ### `RxInstanceUtils.observeAncestry(instance)`
26
-
27
- ### `RxInstanceUtils.observePropertyBrio(instance, property, predicate)`
28
-
29
- ### `RxInstanceUtils.observeLastNamedChildBrio(parent, className, name)`
30
-
31
- ### `RxInstanceUtils.observeChildrenOfClassBrio(parent, className)`
32
-
33
- ### `RxInstanceUtils.observeChildrenBrio(parent, predicate)`
34
-
35
- ### `RxInstanceUtils.observeDescendants(parent, predicate)`
36
-
21
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/instanceutils",
3
- "version": "3.4.1-canary.8533eea.0",
3
+ "version": "3.5.1",
4
4
  "description": "Utility functions involving instances in Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,13 +26,13 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/brio": "3.4.1-canary.8533eea.0",
30
- "@quenty/loader": "3.1.1",
31
- "@quenty/maid": "2.0.1",
32
- "@quenty/rx": "3.4.1-canary.8533eea.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
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "8533eeade3bf6835c0295785c1c326b9abee3222"
37
+ "gitHead": "d146c77d0a8e452824de0ab0b4b03ba0370bcc1b"
38
38
  }
@@ -1,6 +1,14 @@
1
- ---
2
- -- @module RxInstanceUtils
3
- -- @author Quenty
1
+ --[=[
2
+ Utility functions to observe the state of Roblox. This is a very powerful way to query
3
+ Roblox's state.
4
+
5
+ :::tip
6
+ Use RxInstanceUtils to program streaming enabled games, and make it easy to debug. This API surface
7
+ lets you use Roblox as a source-of-truth which is very valuable.
8
+ :::
9
+
10
+ @class RxInstanceUtils
11
+ ]=]
4
12
 
5
13
  local require = require(script.Parent.loader).load(script)
6
14
 
@@ -11,6 +19,13 @@ local Rx = require("Rx")
11
19
 
12
20
  local RxInstanceUtils = {}
13
21
 
22
+ --[=[
23
+ Observes an instance's property
24
+
25
+ @param instance Instance
26
+ @param propertyName string
27
+ @return Observable<T>
28
+ ]=]
14
29
  function RxInstanceUtils.observeProperty(instance, propertyName)
15
30
  assert(typeof(instance) == "Instance", "Not an instance")
16
31
  assert(type(propertyName) == "string", "Bad propertyName")
@@ -27,6 +42,12 @@ function RxInstanceUtils.observeProperty(instance, propertyName)
27
42
  end)
28
43
  end
29
44
 
45
+ --[=[
46
+ Observes an instance's ancestry
47
+
48
+ @param instance Instance
49
+ @return Observable<Instance>
50
+ ]=]
30
51
  function RxInstanceUtils.observeAncestry(instance)
31
52
  local startWithParent = Rx.start(function()
32
53
  return instance, instance.Parent
@@ -35,10 +56,17 @@ function RxInstanceUtils.observeAncestry(instance)
35
56
  return startWithParent(Rx.fromSignal(instance.AncestryChanged))
36
57
  end
37
58
 
38
- -- Returns a brio of the property value
39
- function RxInstanceUtils.observePropertyBrio(instance, property, predicate)
59
+ --[=[
60
+ Returns a brio of the property value
61
+
62
+ @param instance Instance
63
+ @param propertyName string
64
+ @param predicate ((value: T) -> boolean)? -- Optional filter
65
+ @return Observable<Brio<T>>
66
+ ]=]
67
+ function RxInstanceUtils.observePropertyBrio(instance, propertyName, predicate)
40
68
  assert(typeof(instance) == "Instance", "Bad instance")
41
- assert(type(property) == "string", "Bad property")
69
+ assert(type(propertyName) == "string", "Bad propertyName")
42
70
  assert(type(predicate) == "function" or predicate == nil, "Bad predicate")
43
71
 
44
72
  return Observable.new(function(sub)
@@ -47,21 +75,29 @@ function RxInstanceUtils.observePropertyBrio(instance, property, predicate)
47
75
  local function handlePropertyChanged()
48
76
  maid._property = nil
49
77
 
50
- local propertyValue = instance[property]
78
+ local propertyValue = instance[propertyName]
51
79
  if not predicate or predicate(propertyValue) then
52
- local brio = Brio.new(instance[property])
80
+ local brio = Brio.new(instance[propertyName])
53
81
  maid._property = brio
54
82
  sub:Fire(brio)
55
83
  end
56
84
  end
57
85
 
58
- maid:GiveTask(instance:GetPropertyChangedSignal(property):Connect(handlePropertyChanged))
86
+ maid:GiveTask(instance:GetPropertyChangedSignal(propertyName):Connect(handlePropertyChanged))
59
87
  handlePropertyChanged()
60
88
 
61
89
  return maid
62
90
  end)
63
91
  end
64
92
 
93
+ --[=[
94
+ Observes the last child with a specific name.
95
+
96
+ @param parent Instance
97
+ @param className string
98
+ @param name string
99
+ @return Observable<Brio<Instance>>
100
+ ]=]
65
101
  function RxInstanceUtils.observeLastNamedChildBrio(parent, className, name)
66
102
  assert(typeof(parent) == "Instance", "Bad parent")
67
103
  assert(type(className) == "string", "Bad className")
@@ -108,6 +144,13 @@ function RxInstanceUtils.observeLastNamedChildBrio(parent, className, name)
108
144
  end)
109
145
  end
110
146
 
147
+ --[=[
148
+ Observes all children of a specific class
149
+
150
+ @param parent Instance
151
+ @param className string
152
+ @return Observable<Instance>
153
+ ]=]
111
154
  function RxInstanceUtils.observeChildrenOfClassBrio(parent, className)
112
155
  assert(typeof(parent) == "Instance", "Bad parent")
113
156
  assert(type(className) == "string", "Bad className")
@@ -117,6 +160,13 @@ function RxInstanceUtils.observeChildrenOfClassBrio(parent, className)
117
160
  end)
118
161
  end
119
162
 
163
+ --[=[
164
+ Observes all children
165
+
166
+ @param parent Instance
167
+ @param predicate ((value: Instance) -> boolean)? -- Optional filter
168
+ @return Observable<Brio<Instance>>
169
+ ]=]
120
170
  function RxInstanceUtils.observeChildrenBrio(parent, predicate)
121
171
  assert(typeof(parent) == "Instance", "Bad parent")
122
172
  assert(type(predicate) == "function" or predicate == nil, "Bad predicate")
@@ -145,6 +195,13 @@ function RxInstanceUtils.observeChildrenBrio(parent, predicate)
145
195
  end)
146
196
  end
147
197
 
198
+ --[=[
199
+ Observes all descendants that match a predicate
200
+
201
+ @param parent Instance
202
+ @param predicate ((value: Instance) -> boolean)? -- Optional filter
203
+ @return Observable<Brio<Instance>>
204
+ ]=]
148
205
  function RxInstanceUtils.observeDescendants(parent, predicate)
149
206
  assert(typeof(parent) == "Instance", "Bad parent")
150
207
  assert(type(predicate) == "function" or predicate == nil, "Bad predicate")
@@ -1,5 +1,6 @@
1
- ---
2
- -- @module RxInstanceUtils.spec.lua
1
+ --[[
2
+ @class RxInstanceUtils.spec.lua
3
+ ]]
3
4
 
4
5
  local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).load(script)
5
6