Closed zaceno closed 7 years ago
This has the effect of breaking the update
event, in the sense that state will already have newState applied when it's called. For correctness sake, we probably should make a deep clone of state every time, before passing to the action. But that means you can't any longer have recursive references or functions on your state tree. And will probably impact performance. 🤔
Project closing
In hyperapp, you can (and should) make your actions like this:
This is considered safe, because all top level state properties are merged into a new object instance.
In hyperapp-partial the aim is to make the same behavior possible, even though you are working in a branch of the tree state. In order to achieve this, the same action in a partial with the namespace 'foo', becomes essentially this:
Now, this is not technically safe. Because we are modifying a property of the
foo
object. And the foo object instance will not change across actions.It may not be technically safe, but I feel like it's reasonably safe in practice, since the use of hyperapp-partial encourages you to write actions like the first example anyway, leaving all the risk of messing up mutations to the library itself.
But I don't know... I wouldn't mind making it so you always get a new state instance to your partial actions, but I fear performance would suffer. What's your preference?