bring back promise cache

just in case loadWorklets is called more than once
This commit is contained in:
Felix Roos 2024-05-31 10:36:49 +02:00
parent ff85f2307f
commit 07f58c023f

View file

@ -41,8 +41,12 @@ export const getAudioContext = () => {
return audioContext; return audioContext;
}; };
async function loadWorklets() { let workletsLoading;
return await getAudioContext().audioWorklet.addModule(workletsUrl); function loadWorklets() {
if (!workletsLoading) {
workletsLoading = getAudioContext().audioWorklet.addModule(workletsUrl);
}
return workletsLoading;
} }
// this function should be called on first user interaction (to avoid console warning) // this function should be called on first user interaction (to avoid console warning)