-
Notifications
You must be signed in to change notification settings - Fork 18
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
Update init behavior #14
Conversation
: state.sideEffects; | ||
|
||
return { | ||
state: newState.state || prevState.state, |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
have interview during day, will review all tonight |
No rush at all! Good luck today👌 |
closed by #19 |
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 frominit
replace any sideEffects set up ininitialState
.5ff7362
This is slightly tangential but it renames the
newSideEffect
argument to besideEffects
. This makes it so that the update shape mirrors the internal state.Previously, the shapes were:
After this commit, the shapes are:
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.