From 85f70621ef2ce13b88c2b199501f3e5bf9c53822 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Tue, 17 Mar 2020 22:45:59 -0400 Subject: [PATCH] loaded promise allows for downloads to be added while 'loaded' is awaiting --- Tone/core/context/ToneAudioBuffer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tone/core/context/ToneAudioBuffer.ts b/Tone/core/context/ToneAudioBuffer.ts index 948bf617..bf48d7e5 100644 --- a/Tone/core/context/ToneAudioBuffer.ts +++ b/Tone/core/context/ToneAudioBuffer.ts @@ -407,8 +407,10 @@ export class ToneAudioBuffer extends Tone { * Returns a Promise which resolves when all of the buffers have loaded */ static async loaded(): Promise { - await Promise.all(ToneAudioBuffer.downloads); // this makes sure that the function is always async - return Promise.resolve(); + await Promise.resolve(); + while (ToneAudioBuffer.downloads.length) { + await ToneAudioBuffer.downloads[0]; + } } }