Created
December 4, 2018 23:01
-
-
Save Danetag/5cf68ece2084b81eed2b349d37b569a5 to your computer and use it in GitHub Desktop.
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
| let currentView = null; | |
| const pageLoaded = () => { | |
| // "Routing" | |
| const currentPage = document.querySelector("#content").firstElementChild; | |
| switch (currentPage.id) { | |
| case "home-page": | |
| import(/* webpackChunkName: "homepage" */ "pages/homepage/homepage") | |
| .then(currentViewImported) | |
| .catch(error => | |
| console.log( | |
| "An error occurred while loading the Hhmepage component", | |
| error | |
| ) | |
| ); | |
| break; | |
| case "privacy-policy-page": | |
| import(/* webpackChunkName: "privacy" */ "pages/privacy/privacy") | |
| .then(currentViewImported) | |
| .catch(error => | |
| console.log( | |
| "An error occurred while loading privacy component", | |
| error | |
| ) | |
| ); | |
| break; | |
| ... | |
| } | |
| } | |
| const currentViewImported = async ({ default: CurrentModule }) => { | |
| if (currentView) currentView.dispose(); | |
| currentView = new CurrentModule(); | |
| await currentView.init(); | |
| currentView.show(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment