From 26f873e817f4cfdb9a0931b1d45a8ff57044873e Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Wed, 4 Mar 2015 15:13:00 -0800 Subject: [PATCH] Add extra example docs for .add() --- src/Loader.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/Loader.js b/src/Loader.js index 740de91..91eb1a1 100644 --- a/src/Loader.js +++ b/src/Loader.js @@ -132,6 +132,43 @@ module.exports = Loader; /** * Adds a resource (or multiple resources) to the loader queue. * + * This function can take a wide variety of different parameters. The only thing that is always + * required the url to load. All the following will work: + * + * ```js + * loader + * // normal param syntax + * .add('key', 'http://...', function () {}) + * .add('http://...', function () {}) + * .add('http://...') + * + * // object syntax + * .add({ + * name: 'key2', + * url: 'http://...' + * }, function () {}) + * .add({ + * url: 'http://...' + * }, function () {}) + * .add({ + * name: 'key3', + * url: 'http://...' + * onComplete: function () {} + * }) + * .add({ + * url: 'https://...', + * onComplete: function () {}, + * crossOrigin: true + * }) + * + * // you can also pass an array of objects or urls or both + * .add([ + * { name: 'key4', url: 'http://...', onComplete: function () {} }, + * { url: 'http://...', onComplete: function () {} }, + * 'http://...' + * ]); + * ``` + * * @alias enqueue * @param [name] {string} The name of the resource to load, if not passed the url is used. * @param url {string} The url for this resource, relative to the baseUrl of this loader.