Skip to content

Instantly share code, notes, and snippets.

@colevandersWands
Created May 30, 2018 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save colevandersWands/8b2228b32e115e5ad4dc0ab79afff589 to your computer and use it in GitHub Desktop.
Save colevandersWands/8b2228b32e115e5ad4dc0ab79afff589 to your computer and use it in GitHub Desktop.
state store starter
var store = {
debug: true,
nextID: 0,
state: {},
create (newArtist) {
if (this.debug) console.log('created new artist: ' + newArtist);
// create
// call to backend
},
read_one (id) {
if (this.debug) console.log('read artist: ' + id);
// read one locally (from state)
},
read_all () {
// read all from backend and update state
},
update (id, newArtist) {
if (this.debug) console.log('updated artist ' + id + ' with: ' + newArtist)
// call to backend
// update state to match backend
},
remove (id) {
// remove it locally, and sync to backend
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment