Skip to content

Commit

Permalink
Hoist makeStateUpdater into top of scope
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed May 15, 2018
1 parent 681cb25 commit d70b50b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/connect2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ local function noop()
return nil
end

local function makeStateUpdater(store, mapStateToProps)
return function(nextProps, prevState, mappedStoreState)
if mappedStoreState == nil then
mappedStoreState = mapStateToProps(store:getState(), nextProps)
end

local propsForChild = join(nextProps, mappedStoreState, prevState.mappedStoreDispatch)

return {
mappedStoreState = mappedStoreState,
propsForChild = propsForChild,
}
end
end

--[[
mapStateToProps:
(storeState, props) -> partialProps
Expand Down Expand Up @@ -49,21 +64,6 @@ local function connect(mapStateToPropsOrThunk, mapDispatchToProps)
error(message, 2)
end

local function makeStateUpdater(store, mapStateToProps)
return function(nextProps, prevState, mappedStoreState)
if mappedStoreState == nil then
mappedStoreState = mapStateToProps(store:getState(), nextProps)
end

local propsForChild = join(nextProps, mappedStoreState, prevState.mappedStoreDispatch)

return {
mappedStoreState = mappedStoreState,
propsForChild = propsForChild,
}
end
end

local componentName = ("RoduxConnection(%s)"):format(tostring(innerComponent))

local outerComponent = Roact.Component:extend(componentName)
Expand Down

0 comments on commit d70b50b

Please sign in to comment.