Skip to content

Instantly share code, notes, and snippets.

@ahirschberg
Created March 17, 2015 18:35
Show Gist options
  • Select an option

  • Save ahirschberg/d137e5a371ab9891bbe5 to your computer and use it in GitHub Desktop.

Select an option

Save ahirschberg/d137e5a371ab9891bbe5 to your computer and use it in GitHub Desktop.
First attempt at storing UI state for librifox in a dedicated object
function UIState(args) {
this.currentBook = args.currentBook;
this.currentChapter = args.currentChapter;
this.bookCache = args.bookCache; // did not hard-code the coupling with our global bookCache
this.setCurrentBookById = function(id) {
this.currentBook = this.bookCache[id];
return this.currentBook; // should setter methods be returning values?
}
this.setCurrentChapterByIndex = function(index) {
this.currentChapter = this.currentBook.chapters[index];
return this.currentChapter; // should setter methods be returning values?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment