Skip to content

Instantly share code, notes, and snippets.

@rahulsahay19
Created December 21, 2016 12:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rahulsahay19/a69914eb41a77572ca9ce73ffa07206a to your computer and use it in GitHub Desktop.
MovieOps
//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