-
Notifications
You must be signed in to change notification settings - Fork 114
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
Want to use immutable-js map as store, but can't #143
Comments
Yeah, we need to replace |
+1 |
3 similar comments
+1 |
+1 |
+1 |
any update on this ? |
In case you all didn't know, right now you can easily use Map within a store as seen on the docs sample app: https://github.com/acdlite/flummox/blob/master/docs/src/shared/stores/DocStore.js#L12 |
I think most of the solution is already here 😃 https://github.com/acdlite/flummox-immutable-store Looks like import {Record} from 'immutable';
class MyStore extends Store {
constructor() {
const StateRecord = Record({ ...stateObj });
// Set your immutable state here
this.state = new StateRecord();
}
// define how your newState affects your oldState and return merged state
static assignState(oldState, newState) {
if (oldState === undefined || oldState === null) {
const StateRecord = newState.constructor;
oldState = new StateRecord();
}
return oldState.merge(oldState, newState);
}
handler() {
// and you can just use,
this.setState( this.state.set('prop', 'value') );
}
} I think, you can do that to Immutable.Map in a similar way. |
This is the line, where Map becomes broken https://github.com/acdlite/flummox/blob/master/src/addons/reactComponentMethods.js#L75.
And it seems, I can't anyhow configure this behaviour?
The text was updated successfully, but these errors were encountered: