Currently the state object returned by getState and this.state is created by making a serialized copy with this:
JSON.parse(JSON.stringify(state));
Users might want to use an immutable data structure instead. They might want to allow functions or use Object.assign to clone the state. Or any other combination of things.
To keep the API simple, we could just allow each store to define a getState() method to implement it's own cloning (or immutable object wrapping or whatever). It might look something like this:
If we do that, then the question is: should Hoverboard stop cloning the state by default with JSON serialization, and be agnostic by default with a mutable state?
Currently the state object returned by getState and this.state is created by making a serialized copy with this:
Users might want to use an immutable data structure instead. They might want to allow functions or use
Object.assign
to clone the state. Or any other combination of things.To keep the API simple, we could just allow each store to define a
getState()
method to implement it's own cloning (or immutable object wrapping or whatever). It might look something like this:If we do that, then the question is: should Hoverboard stop cloning the state by default with JSON serialization, and be agnostic by default with a mutable state?