Data class makes any object properties deeply observable and associates a listener to execute if the target object changes.
• new Data(source
)
Constructor envolves the source object into the current instance of Data to allow to listen by property and then make it observable.
Name | Type | Description |
---|---|---|
source |
object |
The original object to listen to. |
▸ contains(ref
): boolean
Returns if the current data contains the provided reference.
Name | Type | Description |
---|---|---|
ref |
string |
Reference to search for. |
boolean
true
if the provided data contains the
provided reference.▸ dismiss(ref
, listener?
): void
dismiss function unregisters the provided listener (or all of them if the listener is not provided) for the source data property referenced by the provided reference. If provided reference has not any listener registered the function throws an error.
Name | Type | Default value | Description |
---|---|---|---|
ref |
string |
undefined |
The reference to unregister the listener. |
listener |
Listener |
null |
The listener to dismiss. If any listener is provided, all listener will be dismissed. |
void
▸ dismissAll(listener?
): void
dismissAll function unregisters the provided global listener from the source data. If the listener is not provided, all the global listeners will be dismissed. the source data has not any global listener registered the function throws an error.
Name | Type | Default value | Description |
---|---|---|---|
listener |
Listener |
null |
The global listener to dismiss. If any listener is provided, all listener will be dismissed. |
void
▸ listen(ref
, listener
): void
listen function registers a change listener function for a data source property by the provided refenrence.
Name | Type | Description |
---|---|---|
ref |
string |
The reference to register the listener. |
listener |
Listener |
Function to listen a property change |
void
▸ listenAll(listener
): void
listenAll function registers a global listener function for any data source property.
Name | Type | Description |
---|---|---|
listener |
Listener |
Function to listen an any property change. |
void
▸ refs(): string
[]
Returns a list of attributes references nested. For example, if the data
target has the following definition { attr1: { attr2: false }}
, the
function returns [ “attr1”, “attr1.attr2” ].
string
[]