gsklee / ngStorage

localStorage and sessionStorage done right for AngularJS.
MIT License
2.34k stars 461 forks source link

ngStorage causes digests through entire application #274

Open gildebrand opened 6 years ago

gildebrand commented 6 years ago

I just discovered after some thorough searching in my application that this plugin causes ~10 digests per second. This makes our application feel slow in some parts, and we would really like to get rid of this. I tried commenting out the referenced line, and then our application got way faster.

Why is this line necessary, and what can we do about it? I guess that this is were data is actually persisted, since it's name infers that it's doing some kind of internal digest.

https://github.com/gsklee/ngStorage/blob/b8054d4d9b6691b261c004d06871347e6218d825/ngStorage.js#L206-L208

johannesjo commented 6 years ago

I ran into the same issue. Maybe it's much more efficient to use object getters and setters or Proxy?

igorc2 commented 6 years ago

To solve this issue you can use $evalAsync instead of $apply.