-
Notifications
You must be signed in to change notification settings - Fork 320
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
Fix setState so it handles values #485
Conversation
@@ -53,7 +53,13 @@ export function createStoreConfig(globalConfig, StoreModel) { | |||
return state | |||
} | |||
}, | |||
setState: fn.assign | |||
setState(currentState, nextState) { | |||
if (Object.prototype.toString.call(nextState) === '[object Object]') { |
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.
Maybe pull this out into a fn.isPlainObject
? You use it e.g. at
Line 50 in 44d5814
} else if (Object.prototype.toString.call(state) === '[object Object]') { |
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.
yeah fn.isPlainObject sounds like a good idea. Not sure if I should merge #468 or not. It's a bit dirty to add a property to alt stores and check for them.
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.
With something like #344 it could be a non-issue as you could potentially have a separate overriding implementation of getState
for stores holding immutable data.
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.
Yeah, but #344 opens a whole can of worms in how state is managed and exposes a lot of internals. I'm still conflicted on it.
Conflicts: src/alt/store/index.js
451409e
to
b1d6622
Compare
Fixes #468 |
…values Fix setState so it handles values
When using a store that has state that is a value and not an object we still want to be able to use this.setState