This commit is contained in:
lx
2026-07-06 14:01:11 -04:00
commit c4f97d729d
16468 changed files with 935321 additions and 0 deletions
@@ -0,0 +1,22 @@
--[[
Create a composite reducer from a map of keys and sub-reducers.
]]
local function combineReducers(map)
return function(state, action)
-- If state is nil, substitute it with a blank table.
if state == nil then
state = {}
end
local newState = {}
for key, reducer in pairs(map) do
-- Each reducer gets its own state, not the entire state table
newState[key] = reducer(state[key], action)
end
return newState
end
end
return combineReducers