Closed
Description
I feel it would help many people to mention "Object.freeze" somewhere in the documentation. Maybe some best-practise section when dealing with back-end data.
This becomes very relevant when storing AJAX responses in the state of your component. Usually this data will never change partially, but only as a whole. Not freezing it will heavily impact the performance of the entire component. Freezing the server response (possibly recursively) will prevent this from happening.
Example:
...
data() {
foo: 1,
serverResponse: null
}
...
vm.foo = 2 <- fast
vm.serverResponse = {...} <- large AJAX response
vm.foo = 3 <- very slow
Object.freeze(vm.serverResponse) <- if data are nested you'll need to do deep/recursive freeze
vm.foo = 4 <- fast
I am not familiar with the inner workings of Vue, but I assume this happens because Vue recursively tracks serverResponse properties.
Metadata
Metadata
Assignees
Labels
No labels