-
Notifications
You must be signed in to change notification settings - Fork 5
Description
The kitchen sink demo shows a contrived example whereby within constant mode we use patch-scope to copy then patch an array using a numerically-keyed object.
At the time this was meant to illustrate the low-level simplicity of the underlying algorithm, but when using Patchinko in flavoured mode (constant or immutable), for the purposes of holistic state management, this makes no sense at all.
Lists in application data models tend to be holistic entities: the idea that one would simply merge a short array into a longer array would be a very particular use case; far more intuitive that one would want to replace the array contents wholesale, with immutable replacing the array itself and constant simply splicing out every item.
Before: treat arrays as hashes, iterate over input and patch corresponding keys
After: immutable: replace arrays; constant: target.splice(0, Infinity, input)