Namespace baja.registry
Baja Type Registry
At the core of BajaScript is a lazily loading Type and Contract system. A Contract represents a frozen slot defition for a Complex or a set of FrozenEnum ordinals, tags and display tags
The most commonly used Types are held generated into a Common Type Library that gets
forms part of BajaScript JavaScript library to avoid unnecessary network calls.
Defined in: sys.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Method Attributes | Method Name and Description |
|---|---|
| <private> <static> |
baja.registry.clearStorage()
Clear the registry from permanent storage.
|
| <static> |
baja.registry.getConcreteTypes(obj)
Get an array of concrete Types from the given typeInfo.
|
| <private> <static> |
baja.registry.getOrdScheme(schemeId)
Return the Type for the given ORD scheme name.
|
| <static> |
baja.registry.hasType(typeSpec)
Does the Type exist in the BajaScript registry?
This method will not result in any network calls. |
| <private> <static> |
baja.registry.loadFromStorage()
Load Registry Storage information and return it.
|
|
loadType()
Same as baja#lt.
|
|
| <static> |
baja.registry.loadTypesWithContract()
Same as baja#importTypes.
|
| <private> <static> |
baja.registry.register(obj, updateRegStorageTypes)
Inspect the object structure and create Type information to add to the Registry.
|
| <private> <static> |
baja.registry.saveToStorage(regStorage)
Saves the registry to permanent storage.
|
Method Detail
<private> <static>
baja.registry.clearStorage()
Clear the registry from permanent storage. By default, this does nothing and
must be overridden in a utility library like browser.js to clear the
localStorage (or to a flat file in a server environment, etc).
<static>
baja.registry.getConcreteTypes(obj)
Get an array of concrete Types from the given typeInfo. This method
will make a network call. The type information returned in the
ok handler may not necessarily have Contract information loaded.
To then ensure the Contract information for Complex and FrozenEnums
is loaded, please use baja#importTypes.
This method takes an Object Literal as an argument.
baja.getConcreteTypes({
type: "control:ControlPoint",
ok: function (concreteTypes) {
// Called on success
},
fail: function (err) {
// Called on failure (optional)
},
batch: batch // If specified, network calls are batched into this object
});
- Parameters:
- {Object} obj
- the Object literal for the method's arguments.
- {String|Type} obj.type
- the type or (String type specification - module:typeName) to query the registry for.
- {Function} obj.ok
- the ok callback. When invoked, an array of Types will be passed in as an argument.
- {Function} obj.fail Optional
- the fail callback.
- {baja.comm.Batch} obj.batch Optional
- the batch Buffer. If defined, the network call will be batched into this object.
- See:
- baja.importTypes
- Type
<private> <static>
baja.registry.getOrdScheme(schemeId)
Return the Type for the given ORD scheme name.
- Parameters:
- {String} schemeId
- the ORD scheme name.
- Returns:
- the Type for the ORD Scheme (null is returned if a Type can't be found).
<static>
{Boolean}
baja.registry.hasType(typeSpec)
Does the Type exist in the BajaScript registry?
This method will not result in any network calls.
- Parameters:
- {String} typeSpec
- the type specification to query the registry for.
- Returns:
- {Boolean} true if the Type exists in the BajaScript registry.
<private> <static>
baja.registry.loadFromStorage()
Load Registry Storage information and return it.
By default, this does nothing and must be overriden in a utility library
like browser.js to load from localStorage (or from a flat file in a server
environment, etc).
loadType()
Same as baja#lt.
- See:
- baja.lt
<static>
baja.registry.loadTypesWithContract()
Same as baja#importTypes.
- See:
- baja.importTypes
<private> <static>
baja.registry.register(obj, updateRegStorageTypes)
Inspect the object structure and create Type information to add to the Registry.
This should only be invoked by Tridium developers and is normally used in a network callback.
- Parameters:
- {Object} obj
- the Object structure holding the Type information.
- {Boolean} updateRegStorageTypes Optional
- if true, this will update the Registry storage type database. (Contracts held in the registry storage database will be updated regardless of whether this flag is truthy or not).
<private> <static>
baja.registry.saveToStorage(regStorage)
Saves the registry to permanent storage. By default, this does nothing and
must be overridden in a utility library like browser.js to save to
localStorage (or to a flat file in a server environment, etc).
- Parameters:
- {Object} regStorage
- the BajaScript registry information to store