mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-15 00:07:08 +00:00
loaded promise allows for downloads to be added while 'loaded' is awaiting
This commit is contained in:
parent
faa68aa2d1
commit
85f70621ef
1 changed files with 4 additions and 2 deletions
|
@ -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<void> {
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue