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

Update init behavior #14

Conversation

jamesplease
Copy link
Collaborator

This PR has two commits that to do two separate things:

de98e12
This updates #11 to fully fix #9 by taking sideEffects into account. It ensures that the sideEffects from init replace any sideEffects set up in initialState.

5ff7362
This is slightly tangential but it renames the newSideEffect argument to be sideEffects. This makes it so that the update shape mirrors the internal state.

Previously, the shapes were:

// Update
{
  newState,
  newSideEffect
}

// State
{
  state,
  sideEffects
}

After this commit, the shapes are:

// Update
{
  state,
  sideEffects
}

// State
{
  state,
  sideEffects
}

I think this naming change makes sense in light of #10 . Users should only need to think about having one state imo.


I tested and this seems to be working in my app where I'm using this lib.

: state.sideEffects;

return {
state: newState.state || prevState.state,
Copy link
Collaborator Author

@jamesplease jamesplease Aug 28, 2019

Choose a reason for hiding this comment

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

We may not want to fall back to prevState.state this when this fn is called from init...what do you think @conorhastings ?

Copy link
Owner

Choose a reason for hiding this comment

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

i think you're right, the side effects can return a valid null state or 0 state

Copy link
Owner

Choose a reason for hiding this comment

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

i think if we just change this, tthis and compose are good to go, tried itt out in sample app

Copy link
Owner

Choose a reason for hiding this comment

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

thanks for making this so much better lol

@jamesplease jamesplease mentioned this pull request Aug 28, 2019
@jamesplease jamesplease changed the title Use state not new state update Update init behavior Aug 28, 2019
@conorhastings
Copy link
Owner

have interview during day, will review all tonight

@jamesplease
Copy link
Collaborator Author

No rush at all! Good luck today👌

@conorhastings
Copy link
Owner

closed by #19

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

2 participants