Class: Plugin

Plugin

Abstract class for a Modern Uploader plug-in.

Constructor

new Plugin(name)

Parameters:
Name Type Description
name string A name for this plug-in (optional)
Since:
  • 0.0.0
Source:

Members

(readonly) name :string

A name for this plug-in.
Type:
  • string
Since:
  • 0.0.0
Source:

Methods

(abstract) load(api) → {Promise|undefined}

Called to load this specific plug-in. All setup logic, async or sync, should be completed as part of handling this call. For example, register event handlers here. Do NOT mutate the passed API object directly. Only return a new object that adds new methods or augments existing ones.
Parameters:
Name Type Description
api Core API for core plug-in.
Since:
  • 0.0.0
Source:
Throws:
If there is an immediate issue loading the plug-in.
Type
Error
Returns:
If a Promise is returned, resolve or reject once the outcome is known. Otherwise, return nothing for success or throw for failure. To override existing API methods, or provide new API methods, simply return an object (or pass one through your call to resolve the returned Promise). Any new or overridden methods will be available to all other plug-ins.
Type
Promise | undefined
Example
// simple load implementation
load(api) {
   api.on('add', event => {
      // handle "add" event
   })
}

// adding a new API method
load(api) {
   return {
      sayHi: () => 'hi'
   }
}

// overriding an existing API method
load(api) {
   // Always do this to ensure the original
   // method that you are overriding maintains
   // access to its expected context. Only
   // needed if you intend to call the original
   // method in the new method.
   const oldSayHi = api.add.bind(api)

   return {
      sayHi: () => {
         return oldSayHi() + ' you!'
      }
   }
}