#Best practice on using local storage?

5 messages · Page 1 of 1 (latest)

livid moth
#

Main question is, is it ok to get local storage directly everywhere everytime or should I get it once and store it in a variable (maybe service with a subject). For context, the data will rarely change, is that something to factor in?

grave loom
#

Everytime u pull it from local storage, u need to deserialize it again. So even if the object didnt change, it will be a different object. That limits the amount of optimizations angular can do

#

So personally, I would store it at leasy in a service.

#

But you need to ensure u always have the latest values tho.

covert python
#

I don't know if there are best practices. I think it depends on the use case.
if you take it from a variable, you need to take into account what will happen if the data changes? is it a problem or not?