Record mechanism Require JS (modulejs variant)
Record object
{
path : "foo/bar", // final path/id
needs : [], // should stay intact
fetch : [], // each dependency is destroyed once it's completed
status : 0, // module status; new, loading, pending, complete, failed
context : "http://etc", // root dir containing path
extention : ".js", // will be pasted behind path
node : nodeObj, // first node constructor and later constructed node
factory : function(){}, // module factory
module : undefined, // either: a.) result of factory, b.) object or c.) undefined
timeoutID : 1 // used for script timeouts
}
Status mapping of record
-1 // FAILED
0 // NEW
1 // LOADING
2 // PENDING (rename to LOADED ?)
3 // COMPLETE
Description of what happens at each stage, using status in order:
@status new
Whenever a dependency path is declared and not present in the registry, the following happens.
- a record is created and stored in registry
- status is set to 0 (new)
- context for path is retreived from context mappings (url prefix)
- extention is set to ".js"
- node constructor is set to default ScriptNodeConstructor
- Path expression (if any) methods are executed for record (See path expressions gist).
@loading
Fires per dependency when it's loading html node is constructed and appended to a DOM fragment (before it actually starts the load). At this stage it's futile to tweak relevant attributes required before a load.
- Status is set to 1 (loading)