Classes
Observable
Observable is used when you want to be notified when a change occurs. Use on/off methods to add/remove listener.
Please note that should you be using the
`new Observable({})` constructor, it is **obsolete** since v3.0,
and you have to migrate to the "data/observable" `fromObject({})` or the `fromObjectRecursive({})` functions.Summary
Constructors
Properties
Constructors
constructor
new Observable(): Observable
Returns Observable
Properties
propertyChangeEvent
Static
String value used when hooking to propertyChange event.
Methods
_createPropertyChangeData
_createPropertyChangeData(propertyName: string, value: any, oldValue?: any): PropertyChangeData
This method is intended to be overriden by inheritors to provide additional implementation.
| Parameter | Default | Description |
propertyName | | string |
value | | any |
oldValue | | any |
Returns PropertyChangeData
_emit
| Parameter | Default | Description |
eventNames | | string |
Returns void
addEventListener
addEventListener(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void
Adds a listener for the specified event name.
| Parameter | Default | Description |
eventNames | | stringComma delimited names of the events to attach the listener to. |
callback | | (data: EventData) => voidA function to be called when some of the specified event(s) is raised. |
thisArg | | anyAn optional parameter which when set will be used as "this" in callback method call. |
Returns void
get
Gets the value of the specified property.
| Parameter | Default | Description |
name | | string |
Returns any
hasListeners
Checks whether a listener is registered for the specified event name.
| Parameter | Default | Description |
eventName | | stringThe name of the event to check for. |
Returns boolean
notify
Notify this Observable instance with some data. This causes all event
handlers on the Observable instance to be called, as well as any 'global'
event handlers set on the instance's class.
| Parameter | Default | Description |
data | | Tan object that satisfies the EventData interface, though with
an optional 'object' property. If left undefined, the 'object' property
will implicitly be set as this Observable instance. |
Returns void
notifyPropertyChange
Notifies all the registered listeners for the property change event.
| Parameter | Default | Description |
name | | string |
value | | any |
oldValue | | any |
Returns void
off
on
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void
A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
| Parameter | Default | Description |
eventNames | | stringString corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). |
callback | | (data: EventData) => voidCallback function which will be executed when event is raised. |
thisArg | | anyAn optional parameter which will be used as `this` context for callback execution. |
Returns void
once
once(event: string, callback: (data: EventData) => void, thisArg?: any): void
Adds one-time listener function for the event named
`event`.| Parameter | Default | Description |
event | | stringName of the event to attach to. |
callback | | (data: EventData) => voidA function to be called when the specified event is raised. |
thisArg | | anyAn optional parameter which when set will be used as "this" in callback method call. |
Returns void
removeEventListener
removeEventListener(eventNames: string, callback?: (data: EventData) => void, thisArg?: any): void
Removes listener(s) for the specified event name.
| Parameter | Default | Description |
eventNames | | stringComma delimited names of the events the specified listener is associated with. |
callback | | (data: EventData) => voidAn optional parameter pointing to a specific listener. If not defined, all listeners for the event names will be removed. |
thisArg | | anyAn optional parameter which when set will be used to refine search of the correct callback which will be removed as event listener. |
Returns void
set
Updates the specified property with the provided value.
| Parameter | Default | Description |
name | | string |
value | | any |
Returns void
setProperty
Updates the specified property with the provided value and raises a property change event and a specific change event based on the property name.
| Parameter | Default | Description |
name | | string |
value | | any |
Returns void
addEventListener
Static
off
Static
on
Static
once
Static
- Previous
- NavigationButton
- Next
- ObservableArray