Created
December 21, 2016 12:21
Star
You must be signed in to star a gist
MovieOps
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
//Since, we have moved in module file itself, we don't need to specify module name explicitly, it wil be taken care by require js, which requested it | |
define([], function(){ | |
"use strict"; | |
/* load and save movies */ | |
var STORE_NAME = "movies"; | |
function savemovieData (movies) { | |
localStorage.setItem(STORE_NAME, JSON.stringify(movies)); | |
} | |
function loadmovieData () { | |
var storedmovies = localStorage.getItem(STORE_NAME); | |
if(storedmovies) { | |
return JSON.parse(storedmovies); | |
} | |
return []; | |
} | |
function clearmovieData () { | |
localStorage.removeItem(STORE_NAME); | |
} | |
return{ | |
savemovieData:savemovieData, | |
loadmovieData:loadmovieData, | |
clearmovieData:clearmovieData | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment