Class

ChangeEvent

ChangeEvent

Contains information about changes in a CustomEntity - used in change listeners

Methods

didChange(attributeName) → {boolean}

Returns whether the attribute with the given name was changed.

Parameters:
Name Type Description
attributeName string

Name of the attribute to check

true if the attribute with the given name is among those that were changed

boolean
Example
if (changeEvent.didChange('attribute1')) {
    // do something
}
if (changeEvent.didChange('attribute2')) {
    // do something else
}

getChangedAttributes() → {ArrayLike.<string>}

Returns a set of the names of those attributes which were changed.

Set of names of attributes which were changed

ArrayLike.<string>
Example
var changedAttributes = changeEvent.getChangedAttributes();

getEntity() → {CustomEntity}

Get the CustomEntity which was changed

entity which was changed

CustomEntity
Example
// Get the changed page in change listener
var page = changeEvent.getEntity();
var currentValue = page.get('myAttribute');
var oldValue = changeEvent.getOldValues('myAttribute');

getOldValues(attributeName) → {Object}

Gets the the value(s) of the given attribute before change happened.

For attributes with single value multiplicity the returned object is converted to the correct type. For attributes with multiple values this returns a list of the the old values of the given attribute. If there were no changes for attribute this method returns null.

Parameters:
Name Type Description
attributeName string

Name of the attribute to get the values for

old value(s) of the attribute before the change

Object
Example
// Get the old values of an attribute in change listener
var oldValue = changeEvent.getOldValues('myAttribute');

isNew() → {boolean}

Check whether the entity was created in the change.

Note that for a change listener which is executed upon entity creation a value has to be assigned to the observed attribute, otherwise this will always return false.

true when the entity was created in the change, false when an existing entity was changed.

boolean
Example
if (changeEvent.isNew()) {
    // do something
}