Registry containing global shared objects.
- Version:
- 16.3.5
- Source:
Methods
register(id, sharedObject, displayNameopt) → {Boolean}
stable API
Registers new shared object into Abcs environment.
This method registers your custom shared object you want to use globally from other places throughout Abcs (such as Custom code, calculated Formulas or the Expression builder built into query filters).
Any shared object may be accessed via System.getSharedObject.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
String | unique shared object's identifier.
Should be prefixed with dot-separated package name to make it globally unique.
For example It may derive from the id of a providing ABCS extension (or may be equal), see ExtensionManager. The id cannot end with '.', i.e. the name of the shared object cannot be empty. |
||
sharedObject |
Object | the object to register. |
||
displayName |
String |
<optional> |
id | optional display name for the shared object. The value will represent the object in various ABCS UIs. When not specified part of the id will be used instead. |
- Version:
- 16.3.5
- Source:
- See:
Throws:
-
when invalid id is passed or sharedObject is not provided.
- Type
- Error
Returns:
true
if the object was successfully registered,
false
otherwise (when for example another shared object is
already registered under the same id).
- Type
- Boolean
Examples
// create a simple shared object
var currentTime = {
getTime: function() {
return new Date().toISOString();
}
};
// register a shared object
sharedObjectRegistry.register('com.company.abcs.extensions.currentTime', currentTime);
// get the shared object
var myObject = Abcs.System().getSharedObject('com.company.abcs.extensions.currentTime');
// call shared object's method
var time = myObject.getTime();
Abcs.UI().showNotification(Abcs.UI().Notification.create({
message: 'It is ' + time
});
unregister(id) → {Boolean}
stable API
Removes previously registered shared object from the Abcs environment.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | shared object's identifier. |
- Version:
- 16.3.5
- Source:
Returns:
truthy value if the object was successfully removed
- Type
- Boolean
Example
sharedObjectRegistry.unregister('com.company.abcs.extensions.currentTime');