@quenty/signal 2.2.0 → 2.3.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/LICENSE.md +1 -1
- package/package.json +2 -2
- package/src/Shared/Signal.lua +22 -1
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
|
+
# [2.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/signal@2.2.0...@quenty/signal@2.3.0) (2022-08-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Signal :Once(fn) method ([#285](https://github.com/Quenty/NevermoreEngine/issues/285)) ([9f9f8e3](https://github.com/Quenty/NevermoreEngine/commit/9f9f8e3f0d50f73392271011aa3a37f137ae03fb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/signal@2.1.0...@quenty/signal@2.2.0) (2022-03-27)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/signal
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/signal",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A simple signal implementation for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "4efdac5a9e3433adc7903782e233d805dba568ac"
|
|
33
33
|
}
|
package/src/Shared/Signal.lua
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
--[=[
|
|
2
|
-
Lua-side duplication of the API of events on Roblox objects.
|
|
2
|
+
Lua-side duplication of the [API of events on Roblox objects](https://create.roblox.com/docs/reference/engine/datatypes/RBXScriptSignal).
|
|
3
|
+
|
|
3
4
|
Signals are needed for to ensure that for local events objects are passed by
|
|
4
5
|
reference rather than by value where possible, as the BindableEvent objects
|
|
5
6
|
always pass signal arguments by value, meaning tables will be deep copied.
|
|
@@ -118,6 +119,26 @@ function Signal:Connect(handler)
|
|
|
118
119
|
end)
|
|
119
120
|
end
|
|
120
121
|
|
|
122
|
+
--[=[
|
|
123
|
+
Connect a new, one-time handler to the event. Returns a connection object that can be disconnected.
|
|
124
|
+
@param handler (... T) -> () -- One-time function handler called when `:Fire(...)` is called
|
|
125
|
+
@return RBXScriptConnection
|
|
126
|
+
]=]
|
|
127
|
+
function Signal:Once(handler)
|
|
128
|
+
if not (type(handler) == "function") then
|
|
129
|
+
error(("once(%s)"):format(typeof(handler)), 2)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
return self._bindableEvent.Event:Once(function(key)
|
|
133
|
+
local args = self._argMap[key]
|
|
134
|
+
if args then
|
|
135
|
+
handler(table.unpack(args, 1, args.n))
|
|
136
|
+
else
|
|
137
|
+
error("Missing arg data, probably due to reentrance.")
|
|
138
|
+
end
|
|
139
|
+
end)
|
|
140
|
+
end
|
|
141
|
+
|
|
121
142
|
--[=[
|
|
122
143
|
Wait for fire to be called, and return the arguments it was given.
|
|
123
144
|
@yields
|