Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONModel: Make pSequentialImportCompleted public API #2213

Closed
DerGuteWolf opened this issue Sep 20, 2018 · 9 comments
Closed

JSONModel: Make pSequentialImportCompleted public API #2213

DerGuteWolf opened this issue Sep 20, 2018 · 9 comments

Comments

@DerGuteWolf
Copy link

OpenUI5 version: 1.52/1.56

When defining JSON Models in the manifest.json with a remote URI, it is difficult in a controller to make sure that the data has actually been loaded. When the data has already been loaded when attachRequestCompleted is called, this is never fired.
You have already an internal property pSequentialImportCompleted providing a Promise which would solve this problem. Could you make this Promise officially available?

@RandomByte RandomByte changed the title Please make pSequentialImportCompleted from JSONModel JSONModel: Make pSequentialImportCompleted public API Oct 2, 2018
@RandomByte
Copy link
Member

Hi @DerGuteWolf, thanks for bringing this to our attention. We are tracking this internally as 1880574213.

@RandomByte
Copy link
Member

Hey @DerGuteWolf,

Could you please provide us with an example (e.g. via https://plnkr.co/) that showcases this problem? That would help us a lot.

Thanks and best regards,
Merlin

@DerGuteWolf
Copy link
Author

DerGuteWolf commented Oct 4, 2018

Hi @RandomByte ,

a public example is a bit difficult. The JSON models we use are the SCP HTML5 userapi and an HANA xsjs JSON service. Both vary in the timing enough, so the attachRequestCompleted for these models sometimes works and sometimes does not work. I will try to make an example with some public JSON services.
Regards,
DerGuteWolf

@DerGuteWolf
Copy link
Author

Hi @RandomByte ,
I have now reduced the model and used two public JSON APIs:
https://plnkr.co/edit/EvgR81352zwTmqDpvqdu?p=preview
Be commenting you can try different versions: use attachRequestCompleted for the two models in different sequence, use Promises, use nothing at all to wait for the two models to be ready.
As this depends heavily on the reaction times of the two services you have to try this several times. Most times one of the two attachRequestCompleted will not fire thus you will see nothing. Without waiting the services may be too slow, so you will also see nothing. With promises you will always see both results.
Regards,
DerGuteWolf

@RandomByte
Copy link
Member

Thanks, I forwarded this information to the responsible developer. He'll be in contact with you soon.

@DerGuteWolf
Copy link
Author

Hi @RandomByte ,
any update for this? I was not contacted by a developer so far...
Regards,
DerGuteWolf

@Thodd
Copy link
Contributor

Thodd commented Feb 19, 2019

Hi @DerGuteWolf,

sorry for the late response. We've been working on this and the issue somehow slipped through my fingers lately.

We have a pending commit which will introduce a dataLoaded() function on the JSONModel.
This function will expose the Promise you mentioned, though we need to make some additional refactorings.
We also intent to introduce a Promise as a return value for the loadData calls, so the applications can access the loading state of single data requests as well.

I guess we will merge this in the next days.

Regards,
Thodd

@DerGuteWolf
Copy link
Author

Hi @Thodd, thanks for the update. Please make sure, that this also works für models loaded through the manifest. From your description this seems to be possible, however I wanted to draw your attention to this use case, as we have most problems with it.

@Thodd
Copy link
Contributor

Thodd commented Feb 20, 2019

Hi again @DerGuteWolf,

The dataLoaded function should solve your issue, when accessing the model after it's creation from the manifest. Internally the JSONModel also calls loadData, which now returns a promise which resolves based on the sent request.

BR,
Thodd

@i556484 i556484 added fixed and removed in progress labels Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants