Immutable decorator
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 312
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm trying to get an immutable store going with this:
https://github.com/goatslacker/alt/blob/master/docs/utils/immutable.md
I might be missing something but this doesn't work for me when using bootstrap and iso.
If you were to do something like this:
``` javascript
onDeserialize(data) {
return Immutable.fromJS({
prop1: data.prop1,
prop2: data.prop2
});
}
```
or in the decorator:
``` javascript
onDeserialize: function onDeserialize(data) {
return _immutable2['default'].fromJS(data);
}
```
the state that is passed to onSerialize isn't the immutable map that you would expect.
However, if you were to use a plain old object with immutable values e.g.
``` javascript
GameStore.config = {
onSerialize(state) {
return {
gameData: state.gameData.toJS()
};
},
onDeserialize(data) {
return {
gameData: Immutable.fromJS(data.gameData)
};
}
}
```
it works as I would have thought. Is this correct as it seems at odds with issue #242?
Contributor guide
Research direction
Read docs/utils/immutable.md first, then reproduce the reported behavior with bootstrap and iso using the onSerialize and onDeserialize examples. Compare the immutable-store case with the plain-object case and issue #242; done means the expected state type and serialization behavior are clarified or the discrepancy is reproducibly fixed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100