Class “ChangeListeners”

Object > Observable > Listeners > ChangeListeners

Represents a collection of listeners for a property change event. Differs from its superclass in the constructor signature and the additional values property.

Type: ChangeListeners<Target, Property>
extends Listeners<PropertyChangedEvent<Target, Target[Property]>>
Generics: Target: object
Property: keyof Target
Constructor: public
Singleton: No
Namespace: tabris
Direct subclasses: None
JSX Support: No

Constructor

new ChangeListeners(target, property)

Parameter Type Description
target Target  
property Property  

Properties

values

An observable instance that directly provides the changed values instead of the event object. Also, the current value will be emitted immediately upon subscription. Completes when the target is disposed.

Type: Observable
Settable: No

This property can only be set via constructor. Once set, it cannot change anymore.

PropertyChangedEvent<TargetType, ValueType>

  • JavaScript Type: tabris.EventObject
  • TypeScript Type: PropertyChangedEvent
interface PropertyChangedEvent<TargetType, ValueType> extends EventObject<TargetType>{
  readonly value: ValueType;
  readonly originalEvent: PropertyChangedEvent<object, unknown> | null;
}

An event object fired when an object property changes. It is an instance of EventObject that provides an additional property value containing the new value.

The TypeScript interface is generic with two type parameters, the first is the type of the target and the second is the type of the value that changed.

A PropertyChangedEvent event may also be issued for a property change on a child object. This is supported by the widget data property, and by all properties on ObservableData. In that case the change event on the parent will contain a reference to the change event fired by the child in originalEvent.

Example:

widget.onDataChanged(ev => console.log(ev.originalEvent?.value));
widget.data.foo = 1; // print "1"