hi!
i would like to persistently store data on the client side only.
session is destroyed once the app is closed.
database on the client seems to always be synced with the database on the server (i don’t want to store anything on the server …)
i am looking for something like a cookie.
thanks for your quick reply. it is perfect if the data is stored until the user clears the cache.
is _localstorage a package?
what is the syntax to read and write from local storage?
THANKS!!!
In simple words Meteor._localStorage = window.localStorage. This is a browser storage like a SessionStorage. You can use window.localStorage API, you do not need any package. A little sample:
Meteor.startup ->
localCart = window.localStorage.getItem('localCart')
if localCart
UserCart.insert(localCart)
# now we can watch a cart
UserCart.observe
changed: (doc) ->
window.localStorage.setItem('localCart', doc)
We use alaSQL to maintain a persistent copy of the DB on the client. Works very well but you have to sync it.
Our app works connected and disconnected.