@quenty/rxsignal 7.17.0 → 7.17.1-canary.545.2374fb2.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/RxSignal.lua +43 -11
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
|
+
## [7.17.1-canary.545.2374fb2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rxsignal@7.17.0...@quenty/rxsignal@7.17.1-canary.545.2374fb2.0) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [7.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rxsignal@7.16.2...@quenty/rxsignal@7.17.0) (2025-04-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/rxsignal
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/rxsignal",
|
|
3
|
-
"version": "7.17.0",
|
|
3
|
+
"version": "7.17.1-canary.545.2374fb2.0",
|
|
4
4
|
"description": "Signal API for RxObservables",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/loader": "
|
|
29
|
-
"@quenty/rx": "
|
|
28
|
+
"@quenty/loader": "10.8.1-canary.545.2374fb2.0",
|
|
29
|
+
"@quenty/rx": "13.17.1-canary.545.2374fb2.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "2374fb2b043cfbe0e9b507b3316eec46a4e353a0"
|
|
35
35
|
}
|
package/src/Shared/RxSignal.lua
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
@class RxSignal
|
|
3
4
|
]=]
|
|
@@ -6,18 +7,26 @@ local require = require(script.Parent.loader).load(script)
|
|
|
6
7
|
|
|
7
8
|
local Rx = require("Rx")
|
|
8
9
|
local Observable = require("Observable")
|
|
10
|
+
local _Subscription = require("Subscription")
|
|
9
11
|
|
|
10
12
|
local RxSignal = {}
|
|
11
13
|
RxSignal.ClassName = "RxSignal"
|
|
12
14
|
RxSignal.__index = RxSignal
|
|
13
15
|
|
|
16
|
+
export type RxSignal<T...> = typeof(setmetatable(
|
|
17
|
+
{} :: {
|
|
18
|
+
_observable: Observable.Observable<T...> | () -> Observable.Observable<T...>,
|
|
19
|
+
},
|
|
20
|
+
RxSignal
|
|
21
|
+
))
|
|
22
|
+
|
|
14
23
|
--[=[
|
|
15
24
|
Converts an observable to the Signal interface
|
|
16
25
|
|
|
17
26
|
@param observable Observable<T> | () -> Observable<T>
|
|
18
27
|
@return RxSignal<T>
|
|
19
28
|
]=]
|
|
20
|
-
function RxSignal.new(observable)
|
|
29
|
+
function RxSignal.new<T...>(observable: Observable.Observable<T...> | () -> Observable.Observable<T...>): RxSignal<T...>
|
|
21
30
|
assert(observable, "No observable")
|
|
22
31
|
|
|
23
32
|
local self = setmetatable({}, RxSignal)
|
|
@@ -27,13 +36,42 @@ function RxSignal.new(observable)
|
|
|
27
36
|
return self
|
|
28
37
|
end
|
|
29
38
|
|
|
30
|
-
|
|
39
|
+
--[=[
|
|
40
|
+
Connects to the signal and returns a subscription
|
|
41
|
+
]=]
|
|
42
|
+
function RxSignal.Connect<T...>(self: RxSignal<T...>, callback: (T...) -> ()): _Subscription.Subscription<T...>
|
|
31
43
|
return self:_getObservable():Subscribe(callback)
|
|
32
44
|
end
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
--[=[
|
|
47
|
+
Waits for the signal to fire and returns the values
|
|
48
|
+
]=]
|
|
49
|
+
function RxSignal.Wait<T...>(self: RxSignal<T...>): T...
|
|
50
|
+
local waitingCoroutine = coroutine.running()
|
|
51
|
+
|
|
52
|
+
local subscription: _Subscription.Subscription<T...>
|
|
53
|
+
subscription = self:Connect(function(...)
|
|
54
|
+
subscription:Disconnect()
|
|
55
|
+
task.spawn(waitingCoroutine, ...)
|
|
56
|
+
end)
|
|
57
|
+
|
|
58
|
+
return coroutine.yield()
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
--[=[
|
|
62
|
+
Connects once to the signal and returns a subscription
|
|
63
|
+
]=]
|
|
64
|
+
function RxSignal.Once<T...>(self: RxSignal<T...>, callback: (T...) -> ()): _Subscription.Subscription<T...>
|
|
65
|
+
return self:_getObservable()
|
|
66
|
+
:Pipe({
|
|
67
|
+
Rx.take(1) :: any,
|
|
68
|
+
})
|
|
69
|
+
:Subscribe(callback)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
function RxSignal._getObservable<T...>(self: RxSignal<T...>): Observable.Observable<T...>
|
|
35
73
|
if Observable.isObservable(self._observable) then
|
|
36
|
-
return self._observable
|
|
74
|
+
return self._observable :: Observable.Observable<T...>
|
|
37
75
|
end
|
|
38
76
|
|
|
39
77
|
if type(self._observable) == "function" then
|
|
@@ -47,10 +85,4 @@ function RxSignal:_getObservable()
|
|
|
47
85
|
end
|
|
48
86
|
end
|
|
49
87
|
|
|
50
|
-
|
|
51
|
-
return self:_getObservable():Pipe({
|
|
52
|
-
Rx.take(1);
|
|
53
|
-
}):Subscribe(callback)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
return RxSignal
|
|
88
|
+
return RxSignal
|