Skip to content

Saving / Retrieving Data to/from localStorage #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nelsonic opened this issue Jul 22, 2018 · 1 comment
Closed

Saving / Retrieving Data to/from localStorage #47

nelsonic opened this issue Jul 22, 2018 · 1 comment

Comments

@nelsonic
Copy link
Member

TodoMVC saves the todolist items (list) to localStorage
so that it's still there if the page is refreshed or closed (and returned to).
try it: http://todomvc.com/examples/vanillajs

What is the "MVP" of this?

@nelsonic
Copy link
Member Author

Basic localStorage sample code:

var model = { 'one': 1, 'two': 2, 'three': 3 };

// save the model (data) into storage as a stringified object:
localStorage.setItem('elmish_store', JSON.stringify(model));

// Retrieve the stringified object from localStorage:
var retrieved_model = localStorage.getItem('elmish_store');

console.log('Retrieved model: ', JSON.parse(retrieved_model));

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant