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 |
|
public |
The |
|
public |
The |
|
public |
The |
|
public |
The
|
|
public |
The |
|
public |
The
|
|
public |
The
|
|
public |
The
|
|
public |
The |
|
public |
The |
|
public |
The |
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:
Name | Type | Attribute | Description |
on | Object |
|
Events callbacks When defined at Beloader level, the callback will execute as
many times as the event is received. For instance, a |
autoprocess | boolean |
|
|
async | boolean |
|
|
cache | boolean |
|
|
defer | boolean |
|
|
fallbackSync | boolean |
|
|
xhr | Object |
|
|
loader | Object | Promise |
|
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:
Name | Type | Attribute | Description |
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 |
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:
Name | Type | Attribute | Description |
parent | QueueItem | Calling QueueItem |
public Plugin: Plugin source
A Plugin instance
Properties:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
on | Object |
|
Events callbacks When defined at QueueItem level, the callback will execute if
triggered by itself or its loader. For instance, a |
autoprocess | boolean |
|
if set to |
async | boolean |
|
If |
cache | boolean |
|
If |
defer | boolean |
|
If |
fallbackSync | boolean |
|
If |
id | string |
|
Set the ID for the QueueItem. its main use is in conjunction with |
awaiting | string | string[] |
|
Define the dependency(ies) ID that must be resolved before resolving current QueueItem. |
xhr | object |
|
XHR specific properties for async loading |
xhr.method | string |
|
XHR method to perform request |
xhr.data | mixed |
|
Data to send in the request body. Note: No data processing is done within the core basic XHR instance |
loader | Promise | Object |
|
Custom loaders If provided as a promise callback, the loader will be used for |
loader.sync | Promise |
|
Custom loader for sync requests |
loader.async | Promise |
|
Custom loader for async requests |
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:
Name | Type | Attribute | Description |
target | Loader | Loader instance |
|
data | Event | Native |
public afterprocess: BeloaderEvent source
The afterprocess
event is fired once at the
very end of the loading queue process
Properties:
Name | Type | Attribute | Description |
target | Beloader | Beloader instance |
public beforeprocess: BeloaderEvent source
The beforeprocess
event is fired once at the
very beginning of the loading queue process
Properties:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
target | Loader | Loader instance |
public progress: BeloaderEvent source
The progress
event is fired :
- Always in async mode
- If available in sync mode
Properties:
Name | Type | Attribute | Description |
target | Loader | Loader instance |
|
data | ProgressEvent | Native |
public ready: BeloaderEvent source
Theready
event is fired at the very end of the
item initialization
Properties:
Name | Type | Attribute | Description |
target | QueueItem | QueueItem instance |
public readystatechange: BeloaderEvent source
The progress
event is fired only in async mode
Properties:
Name | Type | Attribute | Description |
target | Loader | Loader instance |
|
data | XMLHttpRequest | Loader xhr instance |
public timeout: BeloaderEvent source
The timeout
event is fired in case of timeout
Properties:
Name | Type | Attribute | Description |
target | Loader | Loader instance |
|
data | Event | Native |