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

Fix setState so it handles values #485

Merged
merged 3 commits into from
Oct 3, 2015

Conversation

goatslacker
Copy link
Owner

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

@@ -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]') {
Copy link
Collaborator

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

} else if (Object.prototype.toString.call(state) === '[object Object]') {
as well.

Copy link
Owner Author

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.

Copy link
Collaborator

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.

Copy link
Owner Author

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.

@goatslacker goatslacker force-pushed the fix-set-state-so-it-handles-values branch from 451409e to b1d6622 Compare October 3, 2015 19:41
@goatslacker
Copy link
Owner Author

Fixes #468

goatslacker added a commit that referenced this pull request Oct 3, 2015
…values

Fix setState so it handles values
@goatslacker goatslacker merged commit 162c0a9 into master Oct 3, 2015
@goatslacker goatslacker deleted the fix-set-state-so-it-handles-values branch October 3, 2015 19:59
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.

3 participants