File: app/components/todo/store.js

Recommend this page to a friend!
  Classes of Sergey Beskorovayniy  >  Hackernews Vue  >  app/components/todo/store.js  >  Download  
File: app/components/todo/store.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Hackernews Vue
View information from Hackernews using Vue.js
Author: By
Last change:
Date: 5 years ago
Size: 392 bytes
 

Contents

Class file image Download
define([], function () {
    
    var STORAGE_KEY = 'todos-vuejs';

    // Methods
    var fetch = function () {
        return JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
    };
    var save = function (todos) {
        localStorage.setItem(STORAGE_KEY, JSON.stringify(todos));
    };

    // Exposed public methods
    return {
        fetch: fetch,
        save: save
    }
});