Source: loader.js

"use strict";


/** 
 * @class Loader
 * @description 
 *   A class to load a file.  This wraps a standard AJAX method and 
 *   Includes an xmit instance to more easily handle events.
 *   the fetch command performs the load and also returns a promise.
 *   <br>
 *   This unit (src/loader.js) is a pseudo class.  This is meant to be compiled with browserify and 
 *   aliasify.  If DEV_MODE environment variable is set to FINAL, this class 
 *   will load _LoaderAtom class, which contains no parameter validations.  Otherwise it 
 *   will load _Loader class which does.
 */

/**  
 * @constructor	
 *   
 * @param {string} url
 * @description default url to be loaded by this class.
 * @param {function} method (optional)
 * @descrition the method to be used . default is GET
 * @param {object} XmitType (optional)
 * @description Allows overriding of the standard Xmit type
 * @param {object} ChannelType (optional)
 * @description Allows overriding of the standard Channel type
 * @memberof Loader
 */

/**
 * @function fetch
 * @description loads a file
 * @param {string} url (optional)
 * @description the url to be loaded.  if none, uses this._url
 * @param {string} method (optional) 
 * @description the method to use when loading.  If none, uses this._method
 * @memberof Loader
 * @returns {object} Promise
 */

/**
 * @function on
 * @description proxies the xmit.on function to the loader API 
 * @param {*} channel_name
 * @description channel_name should be either a number or a string
 * @param {function} lambda (optional) 
 * @description the calback method 
 * @memberof Loader
 * @returns {object} loader instance for continuations
 */
/**
 * @function loaded
 * @description proxies xmit.on(EVS.ON_LOAD) to the loader API
 * @param {function} lambda (optional) 
 * @description the calback method 
 * @memberof Loader
 * @returns {object} loader instance for continuations
 */
/**
 * @function error
 * @description proxies xmit.on(EVS.ON_ERROR) to the loader API
 * @param {function} lambda (optional) 
 * @description the calback method 
 * @memberof Loader
 * @returns {object} loader instance for continuations
 */

/** 
 * @function _on_load
 * @description internal use function to unlock the loader if 
 * a fetch (load) is completed.
 * @memberof Loader
 */
/** 
 * @function _on_error
 * @description internal use function to unlock the loader if 
 * a fetch (load) is throws an error.
 * @memberof Loader
 */