@quenty/rx 13.14.0 → 13.15.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 +11 -0
- package/package.json +4 -4
- package/src/Shared/Rx.lua +18 -24
- package/src/Shared/Subscription.lua +7 -4
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
|
+
# [13.15.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rx@13.14.0...@quenty/rx@13.15.0) (2024-12-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add fail and complete state to Rx ([4bb843b](https://github.com/Quenty/NevermoreEngine/commit/4bb843bfb89c18579a80ba2f11b1d48faa86b48f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [13.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rx@13.13.0...@quenty/rx@13.14.0) (2024-12-03)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/rx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/rx",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.15.0",
|
|
4
4
|
"description": "Quenty's reactive library for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@quenty/cancellabledelay": "^3.5.0",
|
|
31
|
-
"@quenty/canceltoken": "^11.
|
|
31
|
+
"@quenty/canceltoken": "^11.10.0",
|
|
32
32
|
"@quenty/ducktype": "^5.7.1",
|
|
33
33
|
"@quenty/loader": "^10.7.1",
|
|
34
34
|
"@quenty/maid": "^3.4.0",
|
|
35
|
-
"@quenty/promise": "^10.
|
|
35
|
+
"@quenty/promise": "^10.9.0",
|
|
36
36
|
"@quenty/signal": "^7.9.0",
|
|
37
37
|
"@quenty/symbol": "^3.4.0",
|
|
38
38
|
"@quenty/table": "^3.7.0",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "0a20ace4dc7d38f8c889bf73b716b33e8a767c54"
|
|
45
45
|
}
|
package/src/Shared/Rx.lua
CHANGED
|
@@ -242,34 +242,28 @@ function Rx.fromPromise(promise)
|
|
|
242
242
|
assert(Promise.isPromise(promise), "Bad promise")
|
|
243
243
|
|
|
244
244
|
return Observable.new(function(sub)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
-- Save a task.spawn call
|
|
246
|
+
if not promise:IsPending() then
|
|
247
|
+
local results = table.pack(promise:GetResults())
|
|
248
|
+
|
|
249
|
+
if results[1] then
|
|
250
|
+
sub:Fire(table.unpack(results, 2, results.n))
|
|
251
|
+
sub:Complete()
|
|
252
|
+
else
|
|
253
|
+
sub:Fail(table.unpack(results, 2, results.n))
|
|
254
|
+
end
|
|
249
255
|
end
|
|
250
256
|
|
|
251
|
-
|
|
257
|
+
return task.spawn(function()
|
|
258
|
+
local results = table.pack(promise:Yield())
|
|
252
259
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
260
|
+
if results[1] then
|
|
261
|
+
sub:Fire(table.unpack(results, 2, results.n))
|
|
262
|
+
sub:Complete()
|
|
263
|
+
else
|
|
264
|
+
sub:Fail(table.unpack(results, 2, results.n))
|
|
265
|
+
end
|
|
256
266
|
end)
|
|
257
|
-
|
|
258
|
-
promise:Then(
|
|
259
|
-
function(...)
|
|
260
|
-
if pending then
|
|
261
|
-
sub:Fire(...)
|
|
262
|
-
sub:Complete()
|
|
263
|
-
end
|
|
264
|
-
end,
|
|
265
|
-
function(...)
|
|
266
|
-
if pending then
|
|
267
|
-
sub:Fail(...)
|
|
268
|
-
sub:Complete()
|
|
269
|
-
end
|
|
270
|
-
end)
|
|
271
|
-
|
|
272
|
-
return maid
|
|
273
267
|
end)
|
|
274
268
|
end
|
|
275
269
|
|
|
@@ -85,8 +85,9 @@ end
|
|
|
85
85
|
|
|
86
86
|
--[=[
|
|
87
87
|
Fails the subscription, preventing anything else from emitting.
|
|
88
|
+
@param ... any
|
|
88
89
|
]=]
|
|
89
|
-
function Subscription:Fail()
|
|
90
|
+
function Subscription:Fail(...)
|
|
90
91
|
if self._state ~= SubscriptionStateTypes.PENDING then
|
|
91
92
|
return
|
|
92
93
|
end
|
|
@@ -94,7 +95,7 @@ function Subscription:Fail()
|
|
|
94
95
|
self._state = SubscriptionStateTypes.FAILED
|
|
95
96
|
|
|
96
97
|
if self._failCallback then
|
|
97
|
-
self._failCallback()
|
|
98
|
+
self._failCallback(...)
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
self:_doCleanup()
|
|
@@ -157,15 +158,17 @@ end
|
|
|
157
158
|
--[=[
|
|
158
159
|
Completes the subscription, preventing anything else from being
|
|
159
160
|
emitted.
|
|
161
|
+
|
|
162
|
+
@param ... any
|
|
160
163
|
]=]
|
|
161
|
-
function Subscription:Complete()
|
|
164
|
+
function Subscription:Complete(...)
|
|
162
165
|
if self._state ~= SubscriptionStateTypes.PENDING then
|
|
163
166
|
return
|
|
164
167
|
end
|
|
165
168
|
|
|
166
169
|
self._state = SubscriptionStateTypes.COMPLETE
|
|
167
170
|
if self._completeCallback then
|
|
168
|
-
self._completeCallback()
|
|
171
|
+
self._completeCallback(...)
|
|
169
172
|
end
|
|
170
173
|
|
|
171
174
|
self:_doCleanup()
|