Listening to events

You can listen to events by using the on function:

import { Uppload, en } from "uppload";
const uploader = new Uppload({ lang: en });

uploader.on("upload", (url: string) => {
  console.log(`The URL of the uploaded file is: ${url}`);
});

If you want to stop listening to the event, you can use the off function:

const errorLogger = (error: string) => {
  console.log("The error message is", error);
};
uploader.on("error", errorLogger); // Start listening
/* . . . */
uploader.off("error", errorLogger); // Stop listening

You can listen to the following event:

EventDescription
readyPlugin is ready and initialized
bindThe value of a new URL is applied
openPlugin is opened
closePlugin is closed
before-uploadFile upload has started
uploadFile upload has completed
errorFile upload got an error