Created
July 18, 2017 23:39
-
-
Save gauntface/14b1e44338e631a3916f954f2bb95dfa to your computer and use it in GitHub Desktop.
"workbox.js" Concept class for a loader.
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
| class Workbox { | |
| constructor(options) { | |
| console.log('[WorkboxLoader.constructor]', options.packagesPath); | |
| this._packagesPath = options.packagesPath; | |
| // This is required | |
| this.loadModule('workbox-core'); | |
| } | |
| loadModule(moduleName) { | |
| console.log('[Loader.load()] ', moduleName); | |
| importScripts(`${this._packagesPath}/${moduleName}/build/umd.js`); | |
| } | |
| get precaching() { | |
| if (google.workbox.precaching) { | |
| return google.workbox.precaching.default; | |
| } | |
| this.loadModule('workbox-precaching'); | |
| return google.workbox.precaching.default; | |
| } | |
| get routing() { | |
| if (google.workbox.routing) { | |
| return google.workbox.routing.default; | |
| } | |
| this.loadModule('workbox-routing'); | |
| return google.workbox.routing.default; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment