Related question: What is the replacement for metadataLoaded in JSON model?
When I use metadataLoaded in sap.ui.model.odata.v2.ODataModel
, Everytime _onObjectMatched
is called , metadataLoaded
can also be fired.:
this.getRouter().getRoute("object").attachPatternMatched(this._onObjectMatched, this);
_onObjectMatched : function (oEvent) {
var sObjectId = oEvent.getParameter("arguments").objectId;
this.getModel().metadataLoaded().then( function() {
//fired every time
this._bindView(sObjectId);
}.bind(this));
},
But when I use RequestCompleted
in sap.ui.model.json.JSONModel
, RequestCompleted
only fired once when the request data loaded.
this.getModel().attachRequestCompleted(function() {
//fired only once
this._bindView(sObjectId);
});
I am curious why? I think metadata should also be loaded only once?
Update:
Actually, I have already find that metadataLoaded returns a promise (I should have known that when I saw then()
), but just as @Nabi point out, I am not familiar with promise. I should have dig deeper before I ask this question.
The aim of both question is to find an elegant and official replacement for metadataLoaded
in JSON model, should I combine them or sth.?