Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to 3.3.0 to take performance improvement in Signal #99

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/workflows/clabot.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased Changes

## 3.3.0 (2024-11-19)
* Add flag around change to only call traceback() in connection listeners in `__DEV__` ([#98](https://github.com/Roblox/rodux/pull/98))
* Only call traceback() in connection listeners in `__DEV__` ([#78](https://github.com/Roblox/rodux/pull/78))

## 3.2.0 (2023-11-17)
* Add makeThunkMiddleware to inject custom argument ([#94](https://github.com/Roblox/rodux/pull/94)).

Expand Down
2 changes: 1 addition & 1 deletion rotriever.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name = "Rodux"
authors = ["Roblox"]
license = "Apache-2.0"
content_root = "src"
version = "3.2.0"
version = "3.3.0"
45 changes: 29 additions & 16 deletions src/Signal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
Handlers are fired in order, and (dis)connections are properly handled when
executing an event.
]]
local __DEV__ = _G.__DEV__

local _, FFlagRoduxRemoveConnectTraceback = xpcall(function()
return game:DefineFastFlag("RoduxRemoveConnectTraceback", false)
end, function()
return true
end)

local function immutableAppend(list, ...)
local new = {}
local len = #list
Expand Down Expand Up @@ -38,7 +46,7 @@ Signal.__index = Signal
function Signal.new(store)
local self = {
_listeners = {},
_store = store
_store = store,
}

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

if self._store and self._store._isDispatching then
error(
'You may not call store.changed:connect() while the reducer is executing. ' ..
'If you would like to be notified after the store has been updated, subscribe from a ' ..
'component and invoke store:getState() in the callback to access the latest state. '
"You may not call store.changed:connect() while the reducer is executing. "
.. "If you would like to be notified after the store has been updated, subscribe from a "
.. "component and invoke store:getState() in the callback to access the latest state. "
)
end

local listener = {
callback = callback,
disconnected = false,
connectTraceback = debug.traceback(),
disconnectTraceback = nil
connectTraceback = nil,
disconnectTraceback = nil,
}

if not FFlagRoduxRemoveConnectTraceback or __DEV__ then
listener.connectTraceback = debug.traceback()
end

self._listeners = immutableAppend(self._listeners, listener)

local function disconnect()
if listener.disconnected then
error((
"Listener connected at: \n%s\n" ..
"was already disconnected at: \n%s\n"
):format(
tostring(listener.connectTraceback),
tostring(listener.disconnectTraceback)
))
error(
("Listener connected at: \n%s\n" .. "was already disconnected at: \n%s\n"):format(
tostring(listener.connectTraceback),
tostring(listener.disconnectTraceback)
)
)
end

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

if not FFlagRoduxRemoveConnectTraceback or __DEV__ then
listener.disconnectTraceback = debug.traceback()
end
listener.disconnected = true
listener.disconnectTraceback = debug.traceback()
self._listeners = immutableRemoveValue(self._listeners, listener)
end

return {
disconnect = disconnect
disconnect = disconnect,
}
end

Expand All @@ -101,4 +114,4 @@ function Signal:fire(...)
end
end

return Signal
return Signal
Loading