Created
March 17, 2015 18:35
-
-
Save ahirschberg/d137e5a371ab9891bbe5 to your computer and use it in GitHub Desktop.
First attempt at storing UI state for librifox in a dedicated object
This file contains hidden or 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
| 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