dizmojs.Bundle
    Bundle
    
An instance of this class represents a single bundle and
allows reading and setting its attributes where allowed, as well as
registering callbacks to listen for changes. Several convenience methods
are provided to make access easier.
Each dizmo is provided with an instance of this class in the global
variable bundle. It represents the bundle of the dizmo itself. An instance
representing another bundle can be obtained by passing its identifier to
the constructor, or via any method that directly returns an
instance.
new dizmojs.Bundle(id)
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | String | The bundle identifier or a dizmo identifier of the bundle to represent. | 
Throws:
- 
If the provided identifier does not correspond to a bundle
- Type
- 
BundleNotExistsError 
Members
- 
identifier :String
- 
Type:- 
String 
 
- 
Methods
- 
getAttribute(attributeName) → {String|Number}
- 
Get value of an attribute of the bundle (attribute name is case INsensitive!). One can also get the parent attribute: For example dizmo.getAttribute(‘geometry’); will return an object with all the values under geometry. This is recursive, so ALL children on ALL levels below the parent will be retrieved.Parameters:Name Type Argument Description attributeNameString name of the attribute of the bundle. For a list of all attributes, refer to the data-tree. Throws:- 
- 
If the provided attribute name is not a string
- Type
- 
NotAStringError 
 
- 
- 
- 
If the provided attribute does not exist
- Type
- 
AttributeDoesNotExistError 
 
- 
 Returns:value of the Attribute of the viewer- Type
- 
String 
 |Number 
 
- 
- 
subscribeToAttribute(attributeName, callback, subscribedCallback) → {String}
- 
Subscribe a callback to changes on the given attribute. If subscribing on a parent node, the changes that are made to any sub nodes will be listened to. This is as subscribing to a recursive node on the private/public store.Parameters:Name Type Argument Description attributeNameString The attribute on which to listen for changes callbackfunction The function to call once changes have occurred subscribedCallback<optional> The function called once the subscription is registered Throws:- 
- 
If the provided attribute is not a string
- Type
- 
NotAStringError 
 
- 
- 
- 
If the attribute does not exist
- Type
- 
AttributeDoesNotExistError 
 
- 
- 
- 
If the callback is not a function
- Type
- 
NotAFunctionError 
 
- 
 Returns:The subscription id- Type
- 
String 
 
- 
- 
subscribeToAttributeConditional(attributeName, condition, callback, subscribedCallback) → {String}
- 
Subscribe to an attribute and only call the given callback when the attribute is equal to the given conditionParameters:Name Type Argument Description attributeNameString The name of the attribute conditionString 
 |Boolean 
 |Number The value the attribute has to be equal to callbackfunction The function to call once the attribute is equal to the condition subscribedCallback<optional> The function called once the subscription is registered Throws:- 
- 
If the provided attribute name is not a string
- Type
- 
NotAStringError 
 
- 
- 
- 
If the attribute does not exist
- Type
- 
AttributeDoesNotExistError 
 
- 
- 
- 
If the callback is not a function
- Type
- 
NotAFunctionError 
 
- 
 Returns:The subscription id- Type
- 
String 
 
- 
- 
unsubscribeAttribute(subscriptionId)
- 
Unsubscribe from the given attribute changeParameters:Name Type Description subscriptionIdString The subscription id returned from a subscribeToAttribute call Throws:- 
If the given subscription id is not a string
- Type
- 
NotAStringError 
 
- 
- 
getUpdateInformation() → {Object}
- 
Retrieve update information for the bundleReturns:An object representation of the update information- Type
- 
Object 
 
- 
update()
- 
Update the bundle. The dizmos of this bundle have to be reloaded to show changes. A reload of dizmoViewer will also work.
- 
getDizmos() → {Array}
- 
Get all instances of this bundleReturns:An array of dizmojs.Dizmo instances- Type
- 
Array 
 
- 
instantiateDizmo(options, publicProperties, privateProperties, instantiatedCallback)
- 
Instantiate a new dizmoParameters:Name Type Description optionsObject An object containing key/value pairs to set attributes of the dizmo publicPropertiesObject An object containing key/value pairs to set public properties of the dizmo privatePropertiesObject An object containing key/value pairs to set private properties of the dizmo instantiatedCallback<optional> The function called once the dizmo has been instantiated Throws:- 
- 
If the attributes, publicProperties or privateProperties parameters are not objects or undefined.
- Type
- 
NotAnObjectError 
 
- 
- 
- 
If the provided callback is not a function or undefined
- Type
- 
NotAFunctionError 
 
- 
 Examplevar privateKeyValues = new Object({ username: "joedoe", password: "my_secret_password" }); var bundle = viewer.getBundleById('com.dizmo.mybundle'); bundle.instantiateDizmo({}, {}, privateKeyValues, function(dizmoInstance, error) { // do something with dizmoInstance and/or error });
- 
- 
uninstall()
- 
Uninstall the bundle. This only works if there are no more instances (aka Dizmos) of the bundle running.Throws:- 
If the bundle is an internal bundle and can thus not be uninstalled
 If there are still instances of the bundle running
- Type
- 
UninstallBundleError 
 
- 
Type Definitions
- 
onDizmoInstantiatedCallback(dizmoInstance, error)
- 
A callback invoked when the dizmo has been instantiated, or when the instantiating of the dizmo failed.Parameters:Name Type Description dizmoInstanceThe dizmo instance of the newly instantiated dizmo errorObject An error object containing an error number and an error message. 
- 
onSubscriptionRegisteredCallback()
- 
A callback that is called as soon as the subscription has been registered in the dizmoViewer.