DCL

An elegant OOP with mixins + AOP for JavaScript.

New addition: registry

New utility was added to dcl in 2.0.2: registry.

Registry automatically collects all newly-declared constructors, if they define declaredClass property. Later they can be accessed by names. This feature is useful to decouple a declaration of a constructor from places that use it, and for debugging purposes. It provides a Map-like API, so users can inspect and manipulate the registry.

Examples of using registry
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var registry = require('dcl/utils/registry');

// next constructor will be registered automatically
var A = dcl({
    declaredClass: 'A'
    // ...
  });
console.log(registry.has('A'));    // true

var A2 = registry.get('A');
console.log(A === A2);             // true

// let's register more
var B = dcl(A, {
    declaredClass: 'B'
    // ...
  });

// let's inspect the registry
var keys = registry.keys();
console.log('We have', keys.length,
  'registered classes:', keys.join(', '));

var b = new (registry.get('B'))();

// let's unregister A
console.log(registry.delete('A')); // true

// let's unregister all constructors
registry.clear();