Classes

DynamicValue

class DynamicValue()

Base class for values. DynamicValue instances represent value which can be used in data bindings. Some base classes of DynamicValue instances implement a set() method which can be used to modify the value. What exactly the set() method does depends on the implementation. They can be used to implement bindings to backend data, as well as for application interaction.

DynamicValues are similar to BehaviorSubjects in Rx.

DynamicValue.hasValue

Returns true if a value is available.

DynamicValue.isActive

Returns true if this value is currently subscribed to.

DynamicValue.value

Returns the last value received. Throws an error if no value has been received, yet.

DynamicValue.set(value)

Updates the value.

DynamicValue.subscribe(subscriber, replay=true)

Subscribe to this value. Will call the callback argument whenever a value becomes available.

Returns a unsubscribe callback. Calling it will remove the subscription.

Arguments
  • subscriber (function) – Callback function to subscribe.

  • replay (boolean) – Call the subscriber once with the current value (if any).

Returns

function – The unsubscribe callback.

DynamicValue.wait(replay=true)

Wait for a value to be available.

Arguments
  • replay (boolean) – If false, the the current value will be ignored.

Returns

Promise<any>

DynamicValue.fromConstant(value)

Create a value from a constant.

Arguments
  • value – The value to emit.

Returns

DynamicValue

DynamicValue._subscribe()

Internal method implemented by all sub classes. This method will be called when the first subscriber subscribes to this dynamic value.

ListValue

Subclass of DynamicValue for aggregating lists of dynamic values.

class ListValue(values, partial=false, debounce=0)

A special DynamicValue implementation which combines a list of other DynamicValue instances. The ListValue will emit an array of values emitted by that list of dynamic values.

Arguments
  • values (Array.<DynamicValue>) –

  • partial (boolean) – Initial value for the partial property.

  • debounce (number) – Initial value for the debounce property.

ListValue.inSync

This value is in sync if all its represented values are in sync.

ListValue.debounce

The debounce property can be used to throttle the number of value updates. When debounce is a positive number N, value change notifications will be delayed for N milliseconds.

ListValue.partial

The partial property can be used to emit values even if not for each input dynamic value at least one value has been received. The resulting array will contain undefined at those positions.

BackendValue

Subclass of DynamicValue for representing backend data. Will be returned by getBackendValue.

class BackendValue()

Instances of this class represent dynamic values connected to a protocol backend. Internally it interfaces with the API of a backend implementation.

BackendValue.inSync

Returns true if this value is currently synchronized with the backend. This means that currently no value change is pending.

BackendValue.uri

Returns true if this value is currently synchronized with the backend. This means that currently no value change is pending.

IBindingDescription

class IBindingDescription()

An interface describing a binding.

Arguments
  • src (string|Array.<string>) – The src address.

  • srcPrefix (string|Array.<string>) – The source prefix to use.

  • backendValue (DynamicValue) – An explicit backend value to bind to. If a backendValue is specified, src and srcPrefix will be ignored.

  • pipe (function) – An optional pipe operator.

  • transformReceive (function) – An optional function for transforming values received from the backendValue.

  • transformSend (function) – An optional function for transforming values sent to the backendValue.

  • replayReceive (boolean) – If true, one value will be replayed when subscribing to the backendValue.

  • replaySend (boolean) – If true, one value will be replayed when subscribing to the component value. For example, this would send the current option value of the widget to the backend when the binding is created.

  • partial (boolean) – Optional partial parameter used if src specifies a list of sources. This parameter is passed to the resulting ListValue.

  • log (function) – An optional function called for generating log output.

  • debug (boolean) – If true, and log is undefined, log will be set to console.log.

  • debounce (number) – Optional parameter used if a ListValue is created.

Bindings

class Bindings(targetNode, sourceNode=targetNode, ctx=sourceNode, log)

A class for managing a collection of bindings for a node.

Arguments
  • targetNode (Node) – Node to install bindings on.

  • sourceNode (Node) – The source node which initiated this binding. This node is used for calculating the prefix.

  • ctx (*) – The context in which callbacks such as pipe, transformReceive and transformSend is called.

  • log (function) – An optional callback which is called with debug output. This function is expected to have the same signature as console.log.

Bindings.update(bindings)

Update the bindings.

Arguments
  • bindings (Array.<IBindingDescription>|null) –

Bindings.updatePrefix(handle)

Reinitialize all bindings which depend on the prefix with given handle.

Arguments
  • handle (string|null) –

Bindings.dispose()

Remove all bindings.

Option types are classes which are instantiated by the AWML-OPTION component (see OptionComponent). They control how values are connected to the component.

BindOption

class BindOption(options, component)

This option type is used to create two-way bindings between backend values and components.

When this option is created from a OptionComponent the following attributes are parsed on creation and passed as options to the constructor along with those options already parsed by OptionComponent.

  • readonly as the readonly = true if present,

  • writeonly as the writeonly = true if present,

  • sync as the sync option if present,

  • prevent-default as the preventDefault = true option if present,

  • prevent-change as the preventChange = true option if present,

  • transform-send is parsed as JavaScript and passed as transformSend option,

  • transform-receive is parsed as JavaScript and passed as transformReceive option,

  • receive-delay is parsed as an integer and passed as receiveDelay option and

  • ignore-interaction is passed as ignoreInteraction = true if present.

Passes the options readonly, writeonly, sync, preventDefault, ignoreInteraction and receiveDelay to a call to bindingFromComponent.

The option transformSend is a function (or null) which is called to transform a value before it is passed to the backend.

The option transformReceive is a function (or null) which is called to transform a value before it is passed from the backend to the component.

Arguments
  • options (object) – The options for this binding.

  • options.backendValue (DynamicValue) – The backend value to bind to.

  • options.name (string) – The option name in the component to bind to.

  • component (Node) – The component to bind to.

BindOption.BindOption

StaticOption

class StaticOption(options, name, value, component)

This option type is used to set aux widet options to static values.

When this option is created from a OptionComponent the following attributes are parsed on creation and passed as options to the constructor along with those options already parsed by OptionComponent.

  • format is passed as a string as the format option (default is json) and

  • value is passed as parsed according to the format option and passed as the value option.

Arguments
  • options (object) –

  • name (string) – The option name in the component to set.

  • value (*) – The option value in the component to set.

  • component (Node) – The component to set an option on.

MediaOption

class MediaOption(options, component)

This option type can be used to bind CSS media queries to aux widet options.

When this option is created from a OptionComponent the following attributes are parsed on creation and passed as options to the constructor along with those options already parsed by OptionComponent.

  • format is passed as a string as the format option (default is json),

  • values is passed as parsed according to the format option and passed as the values option and

  • media is used to create a MediaQuery using the matchMedia function which is passed as the query option.

Arguments
  • options (object) –

  • options.name (string) – The option name in the component to set.

  • options.values (Array) – An array of length two. The first item in this array is set as the option value when the media queries is false, the second when the media query is true.

  • options.query (MediaQuery) – The media query to subscribe to.

  • component (Node) – The component to set an option on.

BackendBase

class BackendBase()

A base class for backend implementations.

BackendBase.resolvePath(path)

This optional method can be used to resolve the given path to an id which identifies the same parameter.

Arguments
  • path (string) – The path name.

Returns

*|Promise.<*> – The identifier for the given path.

BackendBase.resolveId(id)

This optional method can be used to resolve the given id to the corresponding path.

Arguments
  • id (*) – The identifier.

Returns

*|Promise.<*> – The path.

BackendBase.setByPath(path, value)

Set the value of a parameter with given path name.

Arguments
  • path (string) – The parameter path.

  • value (*) – The parameter value.

Returns

Promise.<*>|undefined

BackendBase.observeInfo(path, callback)

Subscribes to the information about the given path. If successful, this subscription will emit information about the given path.

Arguments
  • path (string) – The path name.

  • callback (ObserveInfoCallback) – The callback.

Returns

function – The unsubscribe function.

BackendBase.fetchInfo(path)

Fetches the information about the given path. If successful, this subscription will emit information about the given path.

Arguments
  • path (string) – The path name.

Returns

IPathInfo – The path information.

BackendBase.observeById(id, callback)

Subscribe to changes of a parameter.

Arguments
  • id (string|number) – The id.

  • callback (ObserveCallback) – The subscription callback.

Returns

function – A unsubscription callback.

BackendBase.observeByPath(path, callback)

Subscribe to changes of a parameter.

Arguments
  • path (string) – The parameter path.

  • callback (ObserveCallback) – The subscription callback.

Returns

function – A unsubscription callback.

BackendBase.supportsIds()

Returns true if this backend uses ids.

BackendBase.callById(id, args)

Calls a method with the given id. This method can only be used on paths which have type function.

Arguments
  • id (string|int) – The unique id of this function.

  • args (Array.<*>) – The arguments to this function.

Returns

Promise.<*> – The return value.

BackendBase.callByPath(id, args)

Calls a method with the given path. This method can only be used on paths which have type function.

Arguments
  • id (string|int) – The unique id of this function.

  • args (Array.<*>) – The arguments to this function.

Returns

Promise.<*> – The return value.

LocalBackend

class LocalBackend()

This class implements a backend which stores parameters in memory. It can be useful when handling temporary parameters (e.g. some form of shared UI state).

It is available with the AWML-BACKEND component using the type local.

LocalBackend.delay

Set an optional delay. Values set on this backend will be emitted after the delay has passed.

LocalStorageBackend

class LocalStorageBackend()

This class implements a backend which stores parameters in either localStorage or sessionStorage.

It is available with the AWML-BACKEND component using the type localstorage.

LocalStorageBackend.storage

The storage object. Should be either localStorage or sessionStorage.

AES70Backend

class AES70Backend()

This class implements a backend for AES70 devices. It uses AES70.js https://github.com/DeutscheSoft/AES70.js which is required to be loaded as one global OCA symbol. It is usually enough to include AES70.es5.js alongside this backend.

The paths used to represent objects and properties of the AES70 device in this backend follow these rules.

  • The path of an object is given by the concatenation of all role names up to the root block delimited by /.

  • The path of a property is given by the paths of the corresponding object concatenated by / and the property name.

  • The path for minimum and maximum values for a property (if defined) are given by the properties path followed by /Min and /Max, respectively.

  • The path of a property followed by /Implemented will emit true or false depending on whether or not the corresponding getter is implemented or not.

Furthermore, it is possible to subscribe to directory contents inside of blocks. These are given by the path of the object followed by a single /. This paths will emit an array with two elements, the first the block itself and the second a Map which contains all children by their role name in order. For example, the content of the root block can be subscribed as the path /.

Note that AES70 does not guarantee, only recommend, that all siblings of a block have unique role names. In order to generate unique path names, this backend will make object paths unique by appending 1, 2, etc..

This backend is available with the AWML-BACKEND component using the type aes70.

EmberPlusBackend

class EmberPlusBackend()

This class implements a backend for the Ember+ protocol. It uses the ember-plus https://github.com/DeutscheSoft/ember-plus which is required to be loaded as the global symbol EmberPlus.

The paths used to represent objects follow the standard Ember+ naming convention. The / character is used as delimiter. The following addresses are supported:

  • Addresses of nodes or parameters will emit the corresponding object from the ember-plus library.

  • Addresses of nodes appended with a / will emit the node object with children populated. It will emit another value whenever the children are changed.

  • Adresses of nodes appended with /identifier will emit the node identifier, /number will emit the node number, /numericPath will emit the node numeric path, isOnline will emit the isOnline flag of the node.

  • Adresses of parameters appended with / and identifier, number, numericPath, key, description, value, minimum, maximum, access, format, enumeration, factor, isOnline, formula, step, default, type, streamIdentifier, enumMap or streamDescriptor will emit the corresponding Ember+ field.

  • Addresses of parameters appended with /effectiveValue, /effectiveMinimum or /effectiveMaximum will emit the value, minimum or maximum fields transformed according to the parameter fields such as factor, step, etc.

All parameters except for /value and /effectiveValue are read-only.

This backend is available with the AWML-BACKEND component using the type emberplus.