Created
August 4, 2020 22:09
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
// Let's pretend Wahoo.Bike.Settings contains at | |
// least the following: | |
Wahoo.Bike.Settings = { | |
FILEPATHS: { | |
MAIN: "folder/file.html", | |
ACCOUNT: "folder/file.html", | |
FRIENDS: "folder/file.html", | |
HISTORY: "folder/file.html", | |
}, | |
VIEWS: { | |
MAIN: "Wahoo Bike", | |
ACCOUNT: "Wahoo Bike Account", | |
FRIENDS: "Wahoo Bike Friends", | |
HISTORY: "Wahoo Biking History", | |
} | |
}; | |
// And now let's imagine a function that will rely on those | |
// variables: | |
Wahoo.Bike.loadView = (viewToLoad) => { | |
// Destructuring for easy access! | |
const { FILEPATHS, VIEWS } = Wahoo.Bike.Settings; | |
switch (viewToLoad) { | |
case VIEWS.ACCOUNT: | |
Server.sync.call('GET', FILEPATHS.ACCOUNT, (response) => { | |
Wahoo.Bike.currentView = VIEWS.ACCOUNT; | |
}); | |
// ... | |
break; | |
case VIEWS.FRIENDS: | |
Server.sync.call('GET', FILEPATHS.FRIENDS, (response) => { | |
Wahoo.Bike.currentView = VIEWS.FRIENDS; | |
}); | |
// ... | |
break; | |
case VIEWS.HISTORY: | |
Server.sync.call('GET', FILEPATHS.HISTORY, (response) => { | |
Wahoo.Bike.currentView = VIEWS.HISTORY; | |
}); | |
// ... | |
break; | |
case VIEWS.MAIN: | |
Server.sync.call('GET', FILEPATHS.MAIN, (response) => { | |
Wahoo.Bike.currentView = VIEWS.MAIN; | |
}); | |
// ... | |
break; | |
default: | |
// ... | |
break; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment