Spaces:
Running
Running
const asyncLibrary = callback => { | |
let data = null; | |
return () => { | |
if (data) return data; | |
return callback() | |
.then(mod => (data = mod.default)); | |
}; | |
}; | |
export const getBackdropLibrary = asyncLibrary( | |
() => import(/* webpackChunkName: "library-backdrops" */ './backdrops.json') | |
); | |
export const getCostumeLibrary = asyncLibrary( | |
() => import(/* webpackChunkName: "library-costumes" */ './costumes.json') | |
); | |
export const getSoundLibrary = asyncLibrary( | |
() => import(/* webpackChunkName: "library-sounds" */ './sounds.json') | |
); | |
export const getSpriteLibrary = asyncLibrary( | |
() => import(/* webpackChunkName: "library-sprites" */ './sprites.json') | |
); | |