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

Rewrite connect2 to be a lot simpler #11

Merged
merged 9 commits into from
May 16, 2018
Merged

Rewrite connect2 to be a lot simpler #11

merged 9 commits into from
May 16, 2018

Conversation

LPGhatguy
Copy link
Contributor

Closes #9.

There are a number of prop/state synchronization bugs in the current connect2 implementation, one of which is outlined in #9. I'm essentially rewriting most of the interesting logic from the ground up.

I'm hoping to pattern some work based on reduxjs/react-redux#919 but while also trying to keep the complexity low. React-Redux's connectAdvanced function seems significantly more complicated than we need.

@coveralls
Copy link

coveralls commented May 15, 2018

Coverage Status

Coverage decreased (-0.05%) to 97.714% when pulling fd11707 on rewrite-connect2 into e210f40 on master.

@LPGhatguy LPGhatguy changed the title WIP: Rewrite connect2 to be a lot simpler and to fix bugs Rewrite connect2 to be a lot simpler May 16, 2018
Copy link
Contributor

@ZoteTheMighty ZoteTheMighty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One gripe about comment clarity, but otherwise I'm good with this change

lib/connect2.lua Outdated
self.mapStateToProps = mapStateToProps

-- All of the values that we put into state are intended to be used
-- by getDerivedStateFromProps, constructed using makeStateUpdater.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, the mappedStoreDispatch is only used in the stateUpdater itself, but both of those contexts have no knowledge of self. Maybe could word this a little more clearly

lib/connect2.lua Outdated
@@ -28,7 +28,7 @@ local function makeStateUpdater(store, mapStateToProps)
-- The caller can optionally provide mappedStoreState if it needed that
-- value beforehand. Doing so is purely an optimization.
if mappedStoreState == nil then
mappedStoreState = mapStateToProps(store:getState(), nextProps)
mappedStoreState = prevState.mapStateToProps(store:getState(), nextProps)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to remove the mapStateToProps argument to makeStateUpdater

Copy link
Contributor

@ZoteTheMighty ZoteTheMighty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think the detailed commenting is better.

@LPGhatguy LPGhatguy merged commit d68b99e into master May 16, 2018
@LPGhatguy LPGhatguy deleted the rewrite-connect2 branch May 16, 2018 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants