Global Functions

APIs in this section are used to interact with registered backends and their parameters.

getBackendValue

getBackendValue(address)

Get the BackendValue for the given address. Addresses have the form <backendName>:<path>.

Arguments
  • address (string) –

Returns

BackendValue

registerBackend

registerBackend(name, backend)

Register a backend under a name.

Arguments
  • name (string) – The backend name.

  • backend (Backend) – The backend object. The backend should be in open state.

unregisterBackend

unregisterBackend(name, backend)

Unregister a backend with the given name.

Arguments
  • name (string) – The backend name.

  • backend (Backend) – The backend object. The backend should be in open state.

getBackend

getBackend(name)

Get the backend currently registered for the given name.

Arguments
  • name (string) – The backend name.

Returns

Backend

waitForBackend

waitForBackend(name)

Waits for a backend with the given name to become available (i.e. open).

Arguments
  • name (string) – The backend name.

Returns

Promise.<Backend>

The APIs in this section are used to interact with parameter prefixes.

setPrefix

setPrefix(node, prefix, handle)

Update the prefix of a node.

Arguments
  • node (Node) – The DOM node.

  • prefix (string) – The prefix value.

  • handle (string|null) – The handle name. If omitted defaults ot null for the default prefix handle.

removePrefix

removePrefix(node, handle)

Remove the prefix of a node.

Arguments
  • node (Node) – The DOM node.

  • handle (string) – The handle name.

collectPrefix

collectPrefix(node, handle)

Calculate the prefix of the given node for the given handle. The prefix is the concatenation of the "prefix" attribute of this node and all its parent nodes. This collection terminates early either

  • if a prefix attribute has the value ":noprefix:" which results in an empty prefix, or

  • if a prefix contains a ":" at which point the prefix is complete.

Arguments
  • node (Node) – The DOM node.

  • handle (string) – The handle name. If given, instead of the "prefix" attribute, the attribute "prefix-" + handle is used.

triggerUpdatePrefix

triggerUpdatePrefix(node, handle)

Tell a node and all its children to recalculate their prefixes.

Arguments
  • node (Node) – The DOM node.

  • handle (string) – The handle name.

registerPrefixTagName

registerPrefixTagName(tagName)

Register the given tagName to be included in the list of components to be notified when a prefix changes on a parent node.

bindingFromWidget

bindingFromWidget(widget, name, options={})
Arguments
  • widget (Widget) – The aux widget to bind to.

  • name (String) – Name of the option to bind to.

  • options (Object) –

  • options.ignoreInteraction (boolean) – If false, values are being delayed while the widget is being interacted with.

  • options.preventDefault (boolean) – If true, the default action of the change is being prevented. The meaning of this depends on the widget and the option bound to.

  • options.preventChange (boolean) – If true, the userset event handler will be used. This implies options.preventDefault=true.

  • options.sync (boolean) – Emit modifications also if they are not triggered by user interaction.

  • options.readonly (boolean) – Only emit option changes, do not allow setting the option using set(). The resulting dynamic value will be readonly.

  • options.writeonly (boolean) – Do not emit any values, only allow setting the widget option using set().

  • options.receiveDelay (number) – Delay values passed to set() for the given number of ms after the user interaction has ended.

Returns

DynamicValue – Returns the dynamic value which represents this binding. Calling set() on this value will set the option on the widget. Values emitted from this dynamic value represent changes of the option.

bindingFromComponent

bindingFromComponent(node, name, options={})
Arguments
  • node (HTMLElement) – The component to bind to.

  • name (String) – Name of the option or property to bind to.

  • options (Object) –

  • options.ignoreInteraction (boolean) – If false, values are being delayed while the widget is being interacted with.

  • options.preventDefault (boolean) – If true, the default action of the change is being prevented. The meaning of this depends on the widget and the option bound to.

  • options.preventChange (boolean) – If true, the event handler will attempt to prevent the change from taking place.

  • options.sync (boolean) – Emit modifications also if they are not triggered by user interaction.

  • options.readonly (boolean) – Only emit option changes, do not allow setting the option using set(). The resulting dynamic value will be readonly.

  • options.writeonly (boolean) – Do not emit any values, only allow setting the widget option using set().

  • options.receiveDelay (number) – Delay values passed to set() for the given number of ms after the user interaction has ended.

Returns

DynamicValue – Returns the dynamic value which represents this binding.

fromDOMEvent

fromDOMEvent(eventTarget, eventName, preventDefault=false, stopPropagation=false)

Creates a dynamic value from a DOM event.

Arguments
  • eventTarget (EventTarget) – The event target.

  • eventName (string) – The event name.

  • preventDefault (bool) – If true, preventDefault() is called on each event.

  • stopPropagation (bool) – If true, stopPropagation() is called on each event.

Returns

DynamicValue.<Event> – Returns the dynamic value representing the DOM event.

connect

connect(value1, replay1=true, transform1, value2, replay2=true, transform2, log)

Connects two dynamic values to each other. Values emitted by one will be set() on the other.

Arguments
  • value1 (DynamicValue) – The first value.

  • replay1 (boolean) – Passed as second argument to value1.subscribe().

  • transform1 (function) – Optional transformation function for values passed from value1 to value2.

  • value2 (DynamicValue) – The second value.

  • replay2 (boolean) – Passed as second argument to value2.subscribe().

  • transform2 (function) – Optional transformation function for values passed from value2 to value1.

  • log (function) – Optional logging function.

Returns

function – Returns a subscription. When called, the connection between the two dynamic values will be removed.

connectTo

connectTo(to, from, replay=true, transform)

Connects the output of one dynamic value to the input of another.

Arguments
  • to (DynamicValue) – The destination of the connection. Values emitted by the value from will be set() on to.

  • from (DynamicValue) – The source of the connection.

  • replay (boolean) – Passed as second argument to subscribe.

  • transform (function) – Optional transformation function for values passed from from to to.

Returns

function – Returns a subscription. When called, the connection between the two dynamic values will be removed.