bring back promise cache
just in case loadWorklets is called more than once
This commit is contained in:
parent
ff85f2307f
commit
07f58c023f
1 changed files with 6 additions and 2 deletions
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue