Add API call to loading queue?

Hi all, is there a simple way to add a (maybe) promise-based API call to the LoaderPlugins loading queue?

Background for that question is:

I already have a simple progress bar showing the image assets download progress. That works perfectly fine. Now I also have some data to preload from an API what should also be respected by this progress bar. Btw, I use this code: Phaser - Examples - Load Progress

I thought it might be possible to insert some custom call into the loading queue so this would be handled like any other LoaderPlugin element.

Something like that:

preload() {
  this.load.image('foo', 'bar.png');
  this.load.image('foo2', 'bar2.png');

  this.load.CUSTOM_API_CALL('baz', async () => { await someApiCall(); });
}

Even if this is not possible…how would you add your data loading to an initial progress bar?

Thanks for any help and wish you all happy new year 2022!
Best, Jan

:wave:

If you just need to fetch JSON and don’t need a promise per se, use load.json(…) and then read the data in a file complete event.

If you need a real promise then try Await loader.

1 Like

Thank you very much! This is awesome, those Rex Plugins seem to have a solution for everything!!!