-
-
Save dasa/9646985 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["require", "exports", "./Storage"], function(require, exports, Storage) { | |
Storage.fetch(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Storage = require("./Storage"); | |
Storage.fetch(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["require", "exports"], function(require, exports) { | |
var Storage = (function () { | |
function Storage() { | |
} | |
Storage.fetch = function () { | |
if (!Storage.todos) { | |
Storage.todos = JSON.parse(localStorage.getItem(Storage.STORAGE_KEY) || '[]'); | |
} | |
return Storage.todos; | |
}; | |
Storage.save = function () { | |
localStorage.setItem(Storage.STORAGE_KEY, JSON.stringify(Storage.todos)); | |
}; | |
Storage.STORAGE_KEY = 'todos-vuejs'; | |
Storage.todos = null; | |
return Storage; | |
})(); | |
return Storage; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Storage{ | |
static STORAGE_KEY:string = 'todos-vuejs'; | |
static todos:any = null; | |
static fetch(){ | |
if( !Storage.todos ){ | |
Storage.todos = JSON.parse( localStorage.getItem( Storage.STORAGE_KEY ) || '[]' ); | |
} | |
return Storage.todos; | |
} | |
static save(){ | |
localStorage.setItem( Storage.STORAGE_KEY , JSON.stringify( Storage.todos ) ); | |
} | |
} | |
export = Storage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment