ngStorage icon indicating copy to clipboard operation
ngStorage copied to clipboard

Custom copy+equality functions

Open wyvern8 opened this issue 10 years ago • 4 comments

Firstly, thanks for maintaining this module - it is really helpful. I've noticed for large objects in a single key, the performance of angular.copy is not great, meaning that ngstorage was identified as a bottleneck in our app due to the frequency at which this is done. After testing a few approaches we found that using angular.fromjson(angular.tojson(obj)) to copy objects within ngstorage to be about 3 times faster for our use case. It would be great if ngstorage could use local overridable functions for both copy and object equality operations in each place they are needed, perhaps defaulting to current implementations - similar to the de/serializer functions. This would also mean people can plugin things like lodash eq+clonedeep. If this is not clear I can send a PR when I get a chance.

wyvern8 avatar Oct 01 '15 20:10 wyvern8

Hey,

Thanks for the comment! Yes this should be easily doable as we already implement the same for serialization/deserialization. And it does make sense.

I'll look into it, if you beat me to it with a PR that is awesome as well :)

egilkh avatar Oct 02 '15 08:10 egilkh

#177 here you go.

wyvern8 avatar Oct 02 '15 11:10 wyvern8

I'm also having performance problems with large objects in a single key.

The best example of this is having a text field with ng-model binded to localstorage variable. When you type on the text field, its lagging a lot. Do you have any ideas how to fix this or should I design the app differently?

Hesesses avatar Oct 21 '15 12:10 Hesesses

For the lagginess, just set debounce in model options.

wyvern8 avatar Feb 24 '16 20:02 wyvern8