Skip to content

Commit 909db6e

Browse files
authored
Merge pull request #99 from pturner-roblox/cherry-pick-3.3.0
Bump to 3.3.0 to take performance improvement in Signal
2 parents 7ee2311 + 2964e52 commit 909db6e

File tree

4 files changed

+34
-38
lines changed

4 files changed

+34
-38
lines changed

.github/workflows/clabot.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased Changes
44

5+
## 3.3.0 (2024-11-19)
6+
* Add flag around change to only call traceback() in connection listeners in `__DEV__` ([#98](https://github.com/Roblox/rodux/pull/98))
7+
* Only call traceback() in connection listeners in `__DEV__` ([#78](https://github.com/Roblox/rodux/pull/78))
8+
59
## 3.2.0 (2023-11-17)
610
* Add makeThunkMiddleware to inject custom argument ([#94](https://github.com/Roblox/rodux/pull/94)).
711

rotriever.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ name = "Rodux"
33
authors = ["Roblox"]
44
license = "Apache-2.0"
55
content_root = "src"
6-
version = "3.2.0"
6+
version = "3.3.0"

src/Signal.lua

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
Handlers are fired in order, and (dis)connections are properly handled when
55
executing an event.
66
]]
7+
local __DEV__ = _G.__DEV__
8+
9+
local _, FFlagRoduxRemoveConnectTraceback = xpcall(function()
10+
return game:DefineFastFlag("RoduxRemoveConnectTraceback", false)
11+
end, function()
12+
return true
13+
end)
14+
715
local function immutableAppend(list, ...)
816
local new = {}
917
local len = #list
@@ -38,7 +46,7 @@ Signal.__index = Signal
3846
function Signal.new(store)
3947
local self = {
4048
_listeners = {},
41-
_store = store
49+
_store = store,
4250
}
4351

4452
setmetatable(self, Signal)
@@ -53,43 +61,48 @@ function Signal:connect(callback)
5361

5462
if self._store and self._store._isDispatching then
5563
error(
56-
'You may not call store.changed:connect() while the reducer is executing. ' ..
57-
'If you would like to be notified after the store has been updated, subscribe from a ' ..
58-
'component and invoke store:getState() in the callback to access the latest state. '
64+
"You may not call store.changed:connect() while the reducer is executing. "
65+
.. "If you would like to be notified after the store has been updated, subscribe from a "
66+
.. "component and invoke store:getState() in the callback to access the latest state. "
5967
)
6068
end
6169

6270
local listener = {
6371
callback = callback,
6472
disconnected = false,
65-
connectTraceback = debug.traceback(),
66-
disconnectTraceback = nil
73+
connectTraceback = nil,
74+
disconnectTraceback = nil,
6775
}
6876

77+
if not FFlagRoduxRemoveConnectTraceback or __DEV__ then
78+
listener.connectTraceback = debug.traceback()
79+
end
80+
6981
self._listeners = immutableAppend(self._listeners, listener)
7082

7183
local function disconnect()
7284
if listener.disconnected then
73-
error((
74-
"Listener connected at: \n%s\n" ..
75-
"was already disconnected at: \n%s\n"
76-
):format(
77-
tostring(listener.connectTraceback),
78-
tostring(listener.disconnectTraceback)
79-
))
85+
error(
86+
("Listener connected at: \n%s\n" .. "was already disconnected at: \n%s\n"):format(
87+
tostring(listener.connectTraceback),
88+
tostring(listener.disconnectTraceback)
89+
)
90+
)
8091
end
8192

8293
if self._store and self._store._isDispatching then
8394
error("You may not unsubscribe from a store listener while the reducer is executing.")
8495
end
8596

97+
if not FFlagRoduxRemoveConnectTraceback or __DEV__ then
98+
listener.disconnectTraceback = debug.traceback()
99+
end
86100
listener.disconnected = true
87-
listener.disconnectTraceback = debug.traceback()
88101
self._listeners = immutableRemoveValue(self._listeners, listener)
89102
end
90103

91104
return {
92-
disconnect = disconnect
105+
disconnect = disconnect,
93106
}
94107
end
95108

@@ -101,4 +114,4 @@ function Signal:fire(...)
101114
end
102115
end
103116

104-
return Signal
117+
return Signal

0 commit comments

Comments
 (0)