Miscellaneous

$U

As introduced in the dependency configuration , you can use a handy notation to identify your files. The $U utility function (an alias for Archetype.getUrl) is the way to convert Archetype's notation into an actual unique URL.

You usually don't need to use this function yourself as each of Archetype's configurations already use this transformation. But if, for any reason, you want to resolve a URL yourself, you can use this function.

			
$U(/*String*/ moduleName[, /*String*/ evaluationType])
			

Converts the moduleName into a real URL. The evaluationType parameter is optional but indicates the file extension to use (Archetype's notation does not contain this information). By default, "js" will be assumed. Example:


Archetype.path = "http://archetypejs.org/";
$U("Archetype.component.graphicalComponent");
//-> "http://archetypejs.org/Archetype/component/graphicalComponent.js"
			

$N and $$N

JavaScript is based on JSON for data reprensentation. We used it a lot for Archetype's configuration and parameters, and we needed a convenient notation to add and extend data. Which is why we created "namespace" notations with short aliases $N and $$N.


//alias for Arhcetype.absoluteNamespace
$N(/*String*/ namespace, /*baseType or Array or HashMap*/ values ...)
			

Creates an absolute namespace for storing values. Absolute indicates that the namespace given as a parameter starts in Archetype.root.


//alias for Arhcetype.relativeNamespace
$$N(/*String*/ namespace, /*baseType or Array or HashMap*/ values ...)
			

Creates a relative namespace for storing values. Relative indicates that a HashMap with keys is returned.

Here are some examples:


$N("foo.bar",{barfoo:5});
//-> Archetype.root.foo.bar.barfoo == 5

$$N("foo.bar", {foobar:5}); 
//-> {foo: {bar: {foobar: 5}}}
			

Archetype.addJS and Archetype.addCSS

Archetype defines two optimized methods to add a JavaScript or a CSS files. For CSS files, there is no callback possible (browsers don't implement it), but for JavaScript files, the addJS method fires a callback when the script is loaded, no matter what browser you use.

Again, this method is used inside the Archetype file loader. You usually don't need to use it directly.


Archetype.addJS(/*String*/ file, /*Function*/ callback [, /*Boolean*/ defer])
			

Adds the file to the page header and launches the callback function when it's ready. The defer parameter is not mandatory and allows you to choose if the defer flag is set in the script tag.


Archetype.addCSS(/*String*/ file)
			

Adds the file in the page header with a link tag.

Archetype.Joiner and Archetype.LoadJoiner

Archetype provides ways to join multiple callbacks in one launch when all callbacks have been fired. If you're using lots of synchronism, which is common in JavaScript, then you will need that kind of possibilities.

Archetype.Joiner is an object you can instantiate in order to join several callbacks.


var myJoiner = new Archetype.Joiner(/*Array*/ keys, /*function*/ callback [, /*boolean*/ debug])
			

Start a joiner with a list of keys. When all keys of the joiner have been fired, the callback will be executed. The debug parameter adds logging to this specific loader.


myJoiner.getJoiner(/*String*/ key, /*Object*/ newData)
			

Returns the function to execute if you want to fire the loader key. newData is an object wich will be extended with all data from other keys in order to be passed as a parameter to the final callback.

Please note that the getJoiner method only returns the function to use to fire the key, without firing it directly.

Archetype.LoadJoiner is an extension of the default loader. It's a specialization of the mecanism for joining on events of one type. It's called LoadJoiner because it is currently only used in the "Component" event which indicates the end of a component's loading.


new Archetype.LoadJoiner(/*String*/ type, /*Array*/ keys, /*function*/ callback [, /*boolean*/ debug])
			

Starts a joiner wich listens for the event "type". Every time the event is called, it fires the key which is the event parameter. When all keys have been fired, the callback function is executed. The debug parameter adds logging to this specific loader.

In LoadJoiner, you don't have to handle the getJoiner method yourself. It's automatically implemented with the event listening.