@quenty/rx 8.0.0 → 8.1.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,14 @@
|
|
|
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
|
+
# [8.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rx@8.0.0...@quenty/rx@8.1.0) (2023-10-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/rx
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [8.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rx@7.16.0...@quenty/rx@8.0.0) (2023-10-11)
|
|
7
15
|
|
|
8
16
|
**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": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Quenty's reactive library for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "ad451bee2ee34d9cad70ff72d0af360db1f91a34"
|
|
44
44
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
@class ObservablePerformance.story
|
|
3
|
+
]]
|
|
4
|
+
|
|
5
|
+
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).load(script)
|
|
6
|
+
|
|
7
|
+
local Observable = require("Observable")
|
|
8
|
+
|
|
9
|
+
return function(_target)
|
|
10
|
+
|
|
11
|
+
local startTime = tick()
|
|
12
|
+
|
|
13
|
+
for _=1, 1000000 do
|
|
14
|
+
local observable = Observable.new(function(sub)
|
|
15
|
+
sub:Fire()
|
|
16
|
+
end)
|
|
17
|
+
|
|
18
|
+
local sub = observable:Subscribe(function()
|
|
19
|
+
-- nooopt
|
|
20
|
+
end)
|
|
21
|
+
|
|
22
|
+
sub:Destroy()
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
print((tick() - startTime) * 1000 .. " ms for 1,000,000")
|
|
26
|
+
|
|
27
|
+
return function()
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
package/src/Shared/Rx.lua
CHANGED
|
@@ -1392,18 +1392,20 @@ end
|
|
|
1392
1392
|
function Rx.combineLatest(observables)
|
|
1393
1393
|
assert(type(observables) == "table", "Bad observables")
|
|
1394
1394
|
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
else
|
|
1404
|
-
latest[key] = value
|
|
1405
|
-
end
|
|
1395
|
+
local initialPending = 0
|
|
1396
|
+
local defaultLatest = {}
|
|
1397
|
+
for key, value in pairs(observables) do
|
|
1398
|
+
if Observable.isObservable(value) then
|
|
1399
|
+
initialPending = initialPending + 1
|
|
1400
|
+
defaultLatest[key] = UNSET_VALUE
|
|
1401
|
+
else
|
|
1402
|
+
defaultLatest[key] = value
|
|
1406
1403
|
end
|
|
1404
|
+
end
|
|
1405
|
+
|
|
1406
|
+
return Observable.new(function(sub)
|
|
1407
|
+
local pending = initialPending
|
|
1408
|
+
local latest = table.clone(defaultLatest)
|
|
1407
1409
|
|
|
1408
1410
|
if pending == 0 then
|
|
1409
1411
|
sub:Fire(latest)
|
|
@@ -37,10 +37,9 @@ local stateTypes = {
|
|
|
37
37
|
@param fireCallback function?
|
|
38
38
|
@param failCallback function?
|
|
39
39
|
@param completeCallback function?
|
|
40
|
-
@param onSubscribe () -> MaidTask
|
|
41
40
|
@return Subscription
|
|
42
41
|
]=]
|
|
43
|
-
function Subscription.new(fireCallback, failCallback, completeCallback
|
|
42
|
+
function Subscription.new(fireCallback, failCallback, completeCallback)
|
|
44
43
|
assert(type(fireCallback) == "function" or fireCallback == nil, "Bad fireCallback")
|
|
45
44
|
assert(type(failCallback) == "function" or failCallback == nil, "Bad failCallback")
|
|
46
45
|
assert(type(completeCallback) == "function" or completeCallback == nil, "Bad completeCallback")
|
|
@@ -51,7 +50,6 @@ function Subscription.new(fireCallback, failCallback, completeCallback, onSubscr
|
|
|
51
50
|
_fireCallback = fireCallback;
|
|
52
51
|
_failCallback = failCallback;
|
|
53
52
|
_completeCallback = completeCallback;
|
|
54
|
-
_onSubscribe = onSubscribe;
|
|
55
53
|
}, Subscription)
|
|
56
54
|
end
|
|
57
55
|
|