goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
23.87k stars 2.23k forks source link

'load' does not get called again after hot reload #1520

Open ben4d85 opened 3 years ago

ben4d85 commented 3 years ago

In a Create React App project, 'load' does not get called again when hot reloading via Command + S.

createSfxHowls() {

    // Create a new howl from the audio file's path
    const howl = new Howl({
        src: mp3Path,
    });

    // Gets called again correctly after save
    console.log("Creating howl...");

    // Is supposed to fire when the howl was loaded successfully
    howl.once('load', () => {

        // Does NOT get called again after save :(
        console.log("Created howl!");
    });
}

Update: The following alternative approach works! Would love to understand why?

const howl = new Howl({
    src: mp3Path,
    onload: () => {
          // Gets called again correctly after save :)
        console.log("Created howl!");
    }
});
luckydonald commented 2 years ago

That "once" sounds like it would be done once.

lustremedia commented 2 years ago

difference between once and on check the documenation