Binding

class Binding

Component property binding base class.

Bindings should be created using the bind and bindf functions, and used as a property of the object passed to Component.with.

Constructor

(source?: string, defaultValue?: any): Binding

.isBinding() static

(value: any): value is Binding

Returns true if given value is an instance of Binding.

.isComponentBinding()

(): true

Method for duck typing, always returns true.

.id

string

Unique ID for this binding.

.propertyName

string

Name of the property that should be observed for this binding (highest level only, does not include names of nested properties or keys).

.bindings

readonly Binding[]

Nested bindings, if any (e.g. for string format bindings, see bindf).

.parent

Binding

Parent binding, if any (e.g. for nested bindings in string format bindings).

.addFilter()

(fmt: string): this

Add a filter to this binding, which transforms values to a specific type or format, optionally localized using the currently registered I18nService. Filters can be chained by adding multiple filters in order of execution.

The argument may be any of the format placeholders that are available for strf, except for comments and plural forms – without the leading % sign or grouping { and }, e.g. s, +8i, .5f, ?, and local:date.

Note: Filters can also be specified after the | (pipe) separator in string argument given to the Binding constructor, or bind function.

.then()

(trueValue: any): this

Add a boolean transform to this binding: use the given value instead of the bound value if that is equal to true (according to the == operator).

.else()

(falseValue: any): this

Add a boolean transform to this binding: use the given value instead of the bound value if that is equal to false (according to the == operator).

Note: Alternatively, use the defaultValue argument to bind() to specify a default value without an extra step.

.match()

(...values: any[]): this

Add a filter to this binding to compare the bound value to the given value(s), the result is always either true (at least one match) or false (none match).

.nonMatch()

(...values: any[]): this

Add a filter to this binding to compare the bound value to the given value(s), the result is always either true (none match) or false (at least one match).

.and()

[1]. (source: Binding): this
[2]. (source: string, defaultValue?: any): this

Add an ‘and’ term to this binding (i.e. logical and, like && operator).

Note: The combined binding can only be bound to a single component, e.g. within a list view cell, bindings targeting both the list element and the activity can not be combined using this method.

.or()

[1]. (source: Binding): this
[2]. (source: string, defaultValue?: any): this

Add an ‘or’ term to this binding (i.e. logical or, like || operator).

Note: The combined binding can only be bound to a single component, e.g. within a list view cell, bindings targeting both the list element and the activity can not be combined using this method.

.debuggerLog()

(): this

Log a message to the console whenever the value of this binding changes, for debugging purposes.

.toString()

(): string

Return a string representation of this binding, for error messages and debug logging.


Binding.Type

Binding type (duck typed).