Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local Storage or other data persistence in elm

Tags:

elm

I am just beginning to look at Elm with the idea of building a simple web application with it. My idea would require to persist some user data in the browser.

Is there a way to handle data persistence directly with Elm? For example in browser session or even local storage? Or should I use ports to do it with JavaScript?

like image 657
marcosh Avatar asked Nov 13 '15 16:11

marcosh


People also ask

Is localStorage data persistent?

localStorage is a property that allows JavaScript sites and apps to save key-value pairs in a web browser with no expiration date. This means the data stored in the browser will persist even after the browser window is closed.

Does local storage persist across sessions?

Local Storage: This read-only interface property provides access to the Document's local storage object, the stored data is stored across browser sessions. Similar to sessionStorage, except that sessionStorage data gets cleared when the page session ends – that is when the page is closed.

Is session storage persistent?

The difference is that with sessionStorage , the data is persisted only until the window or tab is closed. With localStorage , the data is persisted until the user manually clears the browser cache or until your web app clears the data.

What is difference between local storage and session storage in JavaScript?

sessionStorage is similar to localStorage ; the difference is that while data in localStorage doesn't expire, data in sessionStorage is cleared when the page session ends. Whenever a document is loaded in a particular tab in the browser, a unique page session gets created and assigned to that particular tab.


1 Answers

The official answer is "use ports" (for 0.18 - 0.19.1) while awaiting re-publication of Elm's official local storage library: https://github.com/elm-lang/persistent-cache

like image 90
Simon H Avatar answered Sep 24 '22 17:09

Simon H