Last active
November 9, 2019 22:09
-
-
Save matthewstokeley/1bc60a61d1a2eafd532d4f858bcfc5bd to your computer and use it in GitHub Desktop.
a barebones, hacky async route loader
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
// barebones and hacky asynchronous route loader | |
window.addEventListener('load', () => { | |
events.register('click', route); | |
const route = function(event) { | |
let module = event.target.dataset.module; | |
if (module === undefined) module = 'index' | |
return open(module); | |
} | |
const open = function(module) { | |
const req = new Request(config.path.root + config.path.modules + module) | |
return fetch(req).then((res) => { return res.text() }).then((text) => { | |
// appendToDomMethod (text) | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment