Inherits:HTMLElement
The Unit object is the core of BitsmistJS. It inherits from HTMLElement and thus takes over the functionality of a standard HTML element. When creating your own units, you create them by inheriting from this Unit class.
Type:String
Target:Prototype
get
A unique ID assigned to each instance of the unit. It is automatically generated. BITSMIST.V1.Unit static class always returns “00000000-0000-0000-0000-000000000000”.
Type:Object
get
The object that holds assets.
Type:Promise
get
The promise that is resolved when a unit is ready.
Type:*
Target:Prototype
Returns the value from the asset.
Parameter | Type | Description |
---|---|---|
assetName Required | String | The asset name. |
key Required | String | The key in the asset to be retrieved. |
defaultValue | * | Returns this value if the specified key is not found in the asset. |
The value obtained from the asset.
Type:Boolean
Target:Prototype
Returns whether the asset has the specified key.
Parameter | Type | Description |
---|---|---|
assetName Required | String | The asset name. |
key Required | String | The key in the asset to be checked. |
True if the key exists, False if not.
Type:Undefined
Target:Prototype
Sets the value to the asset.
Parameter | Type | Description |
---|---|---|
assetName Required | String | The asset name. |
key Required | String | The key in the asset to be set. |
value | * | The value to set. |
Undefined.
Type:Undefined
static
Upgrades the unit. The type of upgrade varies depending on the type argument.
type | Description |
---|---|
“asset” | Adds the asset to the unit. Specify the asset name for the “name” and content holder for the “content” parameter. |
“method” | Adds the method to the unit. Specify the method name for the “name” and the Function object for “the content” parameter. |
“property” | Adds the property to the unit. Specify the property name for the “name” and the getter/setter for the “content” parameter. |
others | Adds content to the asset specified by the “name” parameter with the “content” parameter. |
Parameter | Type | Description |
---|---|---|
unit Required | Unit | The unit to be upgraded. |
type Required | String | The upgrade type. Valid types are “asset”, “method”, “property” and the asset names. |
name Required | String | The name of the item to be upgraded. |
content Required | * | The content of upgrade. |
Undefined.