Classes
Observable
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
string
Comma delimited names of the events to attach the listener to.
callback
(data: EventData) => void
A function to be called when some of the specified event(s) is raised.
thisArg
any
An 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
string
The 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
T
an 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 β
off(eventNames: string, callback?: (data: EventData) => void, thisArg?: any): void
Shortcut alias to the removeEventListener method.
Returns void
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
string
String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by
`,`
(e.g. "propertyChange", "change").thisArg
any
An 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
string
Name of the event to attach to.
thisArg
any
An 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
string
Comma delimited names of the events the specified listener is associated with.
callback
(data: EventData) => void
An optional parameter pointing to a specific listener. If not defined, all listeners for the event names will be removed.
thisArg
any
An 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
addEventListener(eventName: string, callback: (data: EventData) => void, thisArg?: any): void
Returns void
off β
Static
off(eventName: string, callback?: (data: EventData) => void, thisArg?: any): void
Returns void
on β
Static
on(eventName: string, callback: (data: EventData) => void, thisArg?: any): void
Returns void
once β
Static
once(eventName: string, callback: (data: EventData) => void, thisArg?: any): void
Returns void
- Previous
- NavigationButton
- Next
- ObservableArray