@Override
public boolean observe(Map object, Object key, PropertyObserver observer) {
if (object instanceof ScriptableObject) {
ScriptableObject obj = (ScriptableObject) object;
Context cx = Context.getCurrentContext();
PropertyDescriptor desc = obj.getOwnPropertyDescriptor(cx, key);
if (desc != null && desc.isDataDescriptor()) {
ObserverGetterSetter getterSetter =
new ObserverGetterSetter(obj, key, desc, observer);
obj.defineOwnProperty(cx, key, new PropertyDescriptor(
getterSetter,
getterSetter,
desc.isEnumerable(),
desc.isConfigurable(),
true));
}
return true;
}
return false;