UNPKG

1.73 kBMarkdownView Raw
1Chiχ Loader
2=========
3
4[![Build Status](https://travis-ci.org/psichi/chix-loader.png)](https://travis-ci.org/psichi/chix-loader)
5
6This is the base component loader for Chiχ.
7
8Chiχ uses node definitions to describe each of it's components.
9
10The loader takes care of loading these definitions and caching them.
11
12On top of the base loaders there are loaders which load the definitions from
13a remote server or from the file system.
14
15The base loader accepts definitions added manually.
16
17Definitions are indexed by provider url, but the manual loader uses '@' to indicate
18the definitions are local.
19
20Example usage:
21```javascript
22
23var Loader = require('chix-loader');
24
25var loader = new Loader();
26
27loader.addNodeDefinitions('@', [{
28 ns: 'my', name: 'component',
29 ports: {
30 input: {
31 'in': {
32 type: 'string'
33 }
34 },
35 output: {
36 out: {
37 type: 'string'
38 }
39 }
40 }
41 }, {
42 ns: 'my', name: 'component2',
43 ports: { input: { in: { type: 'string' } } }
44}]);
45
46// retrieve a node definitions from a provider
47loader.getNodeDefinitionFrom('@', 'my', 'component');
48
49// Checks whether the definition is available
50loader.hasNodeDefinition('@', 'my', 'component'); // true
51
52// Given a node and it's map, will try and load the (remote) node.
53// TODO: Explain provider structure within a map
54loader.getNodeDefinition({
55 ns: 'my',
56 name: 'component'
57}, map);
58
59```
60
61# collecting dependencies
62
63It's also the loaders job to collect the dependencies needed to run a graph.
64This is rather simple if a graph only contains non-composite nodes, but quickly
65becomes more complex when subgraphs are used and the number of subgraphs are unknown.
66The loader keeps track of which requires are needed.