registry
Version 2.x
registry
plugs in to dcl
and automatically register all new constructors using declaredClass
property as a key. Users can access constructors by name, enumerate them, and clear the registry selectively by name, or whole.
It is defined in dcl/utils/registry.js
.
Description
registry
returns a singleton with following API:
1 2 3 4 5 6 7 |
|
The registry is updated automatically every time new constructor is created with dcl
, if it defines a name using declaredClass
property.
get(name)
get(name)
takes a constructor name, and returns a constructor function, or undefined
, if it is not found.
has(name)
has(name)
takes a constructor name, and returns true
, if the registry contains such constructor, or false
otherwise.
delete(name)
delete(name)
takes a constructor name, and deletes the corresponding constructor from the registry. The method returns true
, if the operation was successful, or false
otherwise.
keys()
keys()
returns an array of all constructor names in the registry.
clear()
clear()
purges the registry from all registered constructors.
Examples
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 31 32 33 34 35 36 37 38 39 |
|