mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-15 08:17:07 +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
|
* Returns a Promise which resolves when all of the buffers have loaded
|
||||||
*/
|
*/
|
||||||
static async loaded(): Promise<void> {
|
static async loaded(): Promise<void> {
|
||||||
await Promise.all(ToneAudioBuffer.downloads);
|
|
||||||
// this makes sure that the function is always async
|
// 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