Creates a property stub which allows to retrieve the corresponding property value lazily.
Note: Within the callback, the property value shows as undefined and should not be set other than via assignment (no Object.defineProperty
). The function callback should return the actual property's value like that:
sap.ui.require(["sap/base/util/defineLazyProperty"], function(defineLazyProperty){ var oTarget = {}; defineLazyProperty(oTarget, "sProp", function() { return 7; }); console.log(oTarget["sProp"]); // should be 7 });
Param | Type | Default Value | Description |
---|---|---|---|
oTarget | object | Target object of the property stub | |
sProperty | string | Name of the stubbed property | |
fnCallback | function | Function callback which returns the property value | |
sMarker? | function | Marker to allow identification of the according property descriptor like Object.getOwnPropertyDescriptor(oTarget, sProperty).get[sMarker] |
Method | Description |
---|