Use the ManagedObjectObserver
to get notified when properties, aggregations or associations of a ManagedObject
instance have changed.
Use the #observe method to add instances of ManagedObject that should be observed or to enhance the set of observed properties, aggregations etc. for an already observed instance.
Use the #unobserve method to stop observing an instance of ManagedObject or to reduce the set of observed properties, aggregations etc. for an observed instance.
Use the #disconnect method to completely stop observing all instances of ManagedObject hat previously had been added to this observer.
The only parameter to the constructor is a function fnCallback
which will be called for every observed change. Depending on the type of the change, different change objects are passed to the callback:
{string} change.name the name of the property that changed
{string} change.type 'property'
{object} change.object the managed object instance on which the change occurred
{any} change.old the old value
{any} change.current the new value
{string} change.name the name of the aggregation that changed
{string} change.type 'aggregation'
{object} change.object the managed object instance on which the change occurred
{any} change.mutation 'remove' or 'insert'
{sap.ui.base.ManagedObject} change.child the child managed object instance
{string} change.name the name of the association that changed
{string} change.type 'association'
{object} change.object the managed object instance on which the change occurred
{any} change.mutation 'remove' or 'insert'
{string|string[]} change.ids the ids that changed
{string} change.name the name of the event that changed
{string} change.type 'event'
{object} change.object the managed object instance on which the change occurred
{any} change.mutation 'remove' or 'insert'
{object} change.listener the listener object
{object} change.func the listeners function
{object} change.data the events data
{string} change.name the name of the binding that changed
{string} change.type 'binding'
{object} change.object the managed object instance on which the change occurred
{any} change.mutation 'prepare', 'ready' or 'remove'
{object} change.bindingInfo the binding info object
{string} change.memberType 'property' or 'aggregation'
{string} change.type 'destroy'
{object} change.object the managed object instance on which the change occurred
Method | Description |
---|---|
disconnect |
Disconnect the observer from all objects. |
sap.ui.base.ManagedObjectObserver.extend |
Creates a new subclass of class sap.ui.base.ManagedObjectObserver with name
|
sap.ui.base.ManagedObjectObserver.getMetadata |
Returns a metadata object for class sap.ui.base.ManagedObjectObserver. |
isObserved |
Checks whether a given configuration set for a control is observed. All given settings must be observed for the method to return true. |
observe |
Starts observing the given object. A configuration is used to specify the meta data settings that should be observed. Configuration should be as specific as possible to avoid negative performance impact. Observing all settings (properties, aggregations, associations) should be avoided. |
unobserve |
Stops observing the given object. A configuration is used to specify the meta data settings that should be ignored. Configuration should be as specific as possible to avoid negative performance impact. |
Creates a new subclass of class sap.ui.base.ManagedObjectObserver with name sClassName
and enriches it with the information contained in oClassInfo
.
oClassInfo
might contain the same kind of information as described in sap.ui.base.Object.extend.
Param | Type | DefaultValue | Description |
---|---|---|---|
sClassName | string |
Name of the class being created |
|
oClassInfo | object |
Object literal with information about the class |
|
FNMetaImpl | function |
Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class |
Returns a metadata object for class sap.ui.base.ManagedObjectObserver.
Checks whether a given configuration set for a control is observed.
All given settings must be observed for the method to return true.
Param | Type | DefaultValue | Description |
---|---|---|---|
oObject | sap.ui.base.ManagedObject |
the managed object instance that was observed |
|
oConfiguration | object |
a configuration specifying the settings to check for the object. If no configuration is provided it checks if the object observes at least for one property, etc. |
|
properties | boolean string[] |
true if all properties should be checked or list of the property names to check |
|
aggregations | boolean string[] |
true if all aggregations should be checked or list of the aggregation names to check |
|
associations | boolean string[] |
true if all associations should be checked or list of the association names to check |
Starts observing the given object. A configuration is used to specify the meta data settings that should be observed. Configuration should be as specific as possible to avoid negative performance impact. Observing all settings (properties, aggregations, associations) should be avoided.
Param | Type | DefaultValue | Description |
---|---|---|---|
oObject | sap.ui.base.ManagedObject |
the managed object instance to be observed |
|
oConfiguration | object |
a mandatory configuration specifying the settings to observe for the object |
|
properties | boolean string[] |
true if all properties should be observed or list of the property names to observe |
|
aggregations | boolean string[] |
true if all aggregations should be observed or list of the aggregation names to observe |
|
associations | boolean string[] |
true if all associations should be observed or list of the association names to observe |
|
bindings | boolean string[] |
true if all bindings should be observed or list of the binding names to observe |
|
events | boolean string[] |
true if all events should be observed or list of the event names to observe |
|
destroy | boolean |
true if destroy should be observed |
|
parent | boolean |
true if an API parent change should be observed |
Stops observing the given object. A configuration is used to specify the meta data settings that should be ignored. Configuration should be as specific as possible to avoid negative performance impact.
Param | Type | DefaultValue | Description |
---|---|---|---|
oObject | sap.ui.base.ManagedObject |
the managed object instance that was observed |
|
oConfiguration | object |
a configuration specifying the settings to stop observing for the object. If no configuration is provided, the object is unobserved completely |
|
properties | boolean string[] |
true if all properties should be stopped observing or list of the property names to stop observing |
|
aggregations | boolean string[] |
true if all aggregations should be stopped observing or list of the aggregation names to stop observing |
|
associations | boolean string[] |
true if all associations should be stopped observing or list of the association names to stop observing |
|
bindings | boolean string[] |
true if all bindings should be stopped observing or list of the binding names to stop observing |
|
events | boolean string[] |
true if all events should be stopped observing or list of the event names to stop observing |
|
destroy | boolean |
true if destroy should be stopped observing |
|
parent | boolean |
true if a parent change should be stopped observing |