Manual Reference Source Test

Typedef

Static Public Summary
public

Exception for event callbacks, most of the global options are designed to set defaults values for {@link QueueItem) instance and associated Loader instances

public

Stores a BeLoader instance real time progress

Statistics can be accessed using DotObjectArray methods.

public

A loader instance which vary upon the type of asset requested

public

A Plugin instance

public

Options for QueueItem are mostly for the underlying loader.

public

The abort event is fired in case of abort

public

The afterprocess event is fired once at the very end of the loading queue process

public

The beforeprocess event is fired once at the very beginning of the loading queue process

public

The error event is fired if loading is not completed.

public

The load event is fired :

  • Only if loading is succesful
  • Only if loader complete all its task (rendering fonts for instance)
public

The loadend event is emitted at the very end of the loading request.

public

The loadstart event is fired :

  • In sync and async loading mode
  • Just after insertion of the requesting inline tag for sync loading
  • After XMLHttpRequest instance initialization but before sending request for async loading
public

The loadstarted event is fired :

  • Only in async mode
  • Just after sending the request
public

The progress event is fired :

  • Always in async mode
  • If available in sync mode
public

Theready event is fired at the very end of the item initialization

public

The progress event is fired only in async mode

public

The timeout event is fired in case of timeout

Static Public

public BeloaderOptions: Object source

Exception for event callbacks, most of the global options are designed to set defaults values for {@link QueueItem) instance and associated Loader instances

Properties:

NameTypeAttributeDescription
on Object
  • optional

Events callbacks

When defined at Beloader level, the callback will execute as many times as the event is received. For instance, a load callback wille triggered each time an item is loaded.

autoprocess boolean
  • optional
  • default: true

QueueItemOptions

async boolean
  • optional
  • default: true

QueueItemOptions

cache boolean
  • optional
  • default: true

QueueItemOptions

defer boolean
  • optional
  • default: false

QueueItemOptions

fallbackSync boolean
  • optional
  • default: true

QueueItemOptions

xhr Object
  • optional

QueueItemOptions

loader Object | Promise
  • optional

QueueItemOptions

Example:

 var loader = new Beloader({
   defer: true // load in same order than declared
   on: {
     afterprocess: () => { app.start() }
   }
 });

public BeloaderProgress: DotObjectArray source

Stores a BeLoader instance real time progress

Statistics can be accessed using DotObjectArray methods.

Properties:

NameTypeAttributeDescription
items Object

Items count container

items.total number

Total items in Beloader instance

items.waiting number

Total items that are waiting to be processed

items.pending number

Total items that are currently processed

items.processed number

Total items that have been processed

items.loaded number

Total items that have been sucessfully loaded

items.error number

Total items which load have failed on error

items.abort number

Total items which load have been aborted

items.timeout number

Total items wich load have failed on timeout

items.ready number

Total items that have been loaded and post-process finished

loading Object

Loading statistics

loading.start timestamp

Process start timestamp

loading.end timestamp

Process end timestamp

loading.elapsed number

Duration of the process (ms)

loading.loaded number

Weight of loaded data. It might not be accurate because relying on src/events/typedef.doc.js~progress event

loading.rate number

Transfer bandwidth. It might not be accurate because relying on progress event

loading.complete number

Loading percentage completed. It might not be accurate because relying on progress QueueItem event

loading.total number

Weight of data to load. It might not be accurate because relying on progress QueueItem event and server's providing a content-length header.

Example:

 var loader = new Beloader({
   defer: true // load in same order than declared
   on: {
     afterprocess: () => { app.start() }
   }
 });
 
 loader.fetchAll({
   'js': 'https://cdn.jsdelivr.net/npm/elementify@latest',
   'font': {
     webfont: {
       google: {
         families: ['Droid Sans', 'Droid Serif']
       }
     }
   },
   'js': 'https://myserver.com/myapp.js'
 });
 
 loader.progress.data.items.total; // returns 2
 loader.progress.pull('items.total'); // returns 2

public Loader: Loader source

A loader instance which vary upon the type of asset requested

Properties:

NameTypeAttributeDescription
parent QueueItem

Calling QueueItem

public Plugin: Plugin source

A Plugin instance

Properties:

NameTypeAttributeDescription
parent Beloader

Calling QueueItem

public QueueItemOptions: Object source

Options for QueueItem are mostly for the underlying loader. Some loaders are requiring specific informations and will usually throw an error if not provided

Properties:

NameTypeAttributeDescription
on Object
  • optional

Events callbacks

When defined at QueueItem level, the callback will execute if triggered by itself or its loader. For instance, a load callback wille be triggered once when the item will be loaded.

autoprocess boolean
  • optional
  • default: true

if set to false, each item must be processed by calling its process method or Beloader instance process method for a bulk run

async boolean
  • optional
  • default: true

If true, QueueItem will first try to process request asynchronously

cache boolean
  • optional
  • default: true

If false, QueueItem will append a unique hash as query string to the request url to disable browser's built-in cache

defer boolean
  • optional
  • default: false

If true, QueueItem will not resolve until all previous requested items which have also defer option set to true is resolved

fallbackSync boolean
  • optional
  • default: true

If true, QueueItem will try to perform a sync request as fallback. It can be a workaround for CORS issues.

id string
  • optional

Set the ID for the QueueItem. its main use is in conjunction with awaiting option

awaiting string | string[]
  • optional

Define the dependency(ies) ID that must be resolved before resolving current QueueItem.

xhr object
  • optional

XHR specific properties for async loading

xhr.method string
  • optional
  • default: 'GET'

XHR method to perform request

xhr.data mixed
  • optional

Data to send in the request body. Note: No data processing is done within the core basic XHR instance

loader Promise | Object
  • optional

Custom loaders

If provided as a promise callback, the loader will be used for custom type requests. Alternatively, you can provide loader replacements for known types (see below)

loader.sync Promise
  • optional

Custom loader for sync requests

See AbstractLoader#sync

loader.async Promise
  • optional

Custom loader for async requests

See AbstractLoader#async

Example:

 var loader = new Beloader();
 
 loader.fetch('script', {
   url: 'https://cdn.jsdelivr.net/npm/elementify@latest',
   async: false
 }); 

public abort: BeloaderEvent source

The abort event is fired in case of abort

Properties:

NameTypeAttributeDescription
target Loader

Loader instance

data Event

Native abort event

public afterprocess: BeloaderEvent source

The afterprocess event is fired once at the very end of the loading queue process

Properties:

NameTypeAttributeDescription
target Beloader

Beloader instance

public beforeprocess: BeloaderEvent source

The beforeprocess event is fired once at the very beginning of the loading queue process

Properties:

NameTypeAttributeDescription
target Beloader

Beloader instance

public error: BeloaderEvent source

The error event is fired if loading is not completed. It will be fired in case of error, abort or timeout

Properties:

NameTypeAttributeDescription
target QueueItem

QueueItem instance

data mixed

Additionnal informations or native event

public load: BeloaderEvent source

The load event is fired :

  • Only if loading is succesful
  • Only if loader complete all its task (rendering fonts for instance)

Properties:

NameTypeAttributeDescription
target QueueItem

QueueItem instance

public loadend: BeloaderEvent source

The loadend event is emitted at the very end of the loading request. It will occur whenever the loading succeeds or fails

Properties:

NameTypeAttributeDescription
target QueueItem

QueueItem instance

public loadstart: BeloaderEvent source

The loadstart event is fired :

  • In sync and async loading mode
  • Just after insertion of the requesting inline tag for sync loading
  • After XMLHttpRequest instance initialization but before sending request for async loading

If you want to tweak XHR instance without providing a full one, you can use this callback. The XHR instance will be available as a loader property (see example).

Properties:

NameTypeAttributeDescription
target Loader

Loader instance

Example:

 var loader = new Beloader() ;

 loader.fetch('json', {
  url: 'http://jsonserverwithbadheaders.com/api',
  on: {
    loadstart: function(event) {
      // loader is available in event.target
      // Override the default json responseType value to prevent errors
      event.target.xhr.responseType = "text"
    }
  }
 }).then((item) => var myGoodJson = strangeStringProcess(item.loader.xhr.response));

public loadstarted: BeloaderEvent source

The loadstarted event is fired :

  • Only in async mode
  • Just after sending the request

Properties:

NameTypeAttributeDescription
target Loader

Loader instance

public progress: BeloaderEvent source

The progress event is fired :

  • Always in async mode
  • If available in sync mode

Properties:

NameTypeAttributeDescription
target Loader

Loader instance

data ProgressEvent

Native progress event

public ready: BeloaderEvent source

Theready event is fired at the very end of the item initialization

Properties:

NameTypeAttributeDescription
target QueueItem

QueueItem instance

public readystatechange: BeloaderEvent source

The progress event is fired only in async mode

Properties:

NameTypeAttributeDescription
target Loader

Loader instance

data XMLHttpRequest

Loader xhr instance

public timeout: BeloaderEvent source

The timeout event is fired in case of timeout

Properties:

NameTypeAttributeDescription
target Loader

Loader instance

data Event

Native timeout event