- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 01:28 AM
Hi everybody,
I'm struggeling again with a maybe easy topic but dont know how to proceed.
I have a google maps widget on my index page which gets loads at requesting index page.
My serverside script retrieves information from an rest service. That rest service provides geo information to be shown on the google map. The problem is, that this rest service is realy slow so my index page doenst show up before the rest service returns.
How can i asynchronously call my rest service while showing the page and update google maps with my geo information when the service gets back. I tried RESTMessageV2 - executeAsync() but that didnt help at all. I still need to wait till rest service returns.
May somebody help me
best regards,
Felix
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 03:33 AM
Hi Felix,
To make the page load and run the server side async make use of the input object or lack thereof. For example in the server side use
....
if(!input) {
// returning when there isn't any input will allow the page to load
return;
}
// any code below this check won't run unless some kind of input is sent
.....
If you have quick server side calls that must pull information on first load of the page then put that above your check for no input.
Place your large data REST call after the check for no input.
In the client controller kick off the REST call by using the ".server.get([Object])" method.
For example you might have a loader indicator in lieu of your map while it's fetching the data and might do something like this:
c.getMapData = function(action) {
c.loadingIndicator = true;
c.server.get({someInput:'inputs'}).then(function(response){
c.loadingIndicator = false;
c.data.map_data = response.data.map_data
})
};
c.getMapData();
Hope this helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 01:48 AM
You can make a event and after that create a script action which will run when your event is called.
It will run asynchronously.
Please mark my answer correct and helpful if my answer helped u. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 03:00 AM
May you also explain shortly how i can update a frontend element from that script action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 03:33 AM
Hi Felix,
To make the page load and run the server side async make use of the input object or lack thereof. For example in the server side use
....
if(!input) {
// returning when there isn't any input will allow the page to load
return;
}
// any code below this check won't run unless some kind of input is sent
.....
If you have quick server side calls that must pull information on first load of the page then put that above your check for no input.
Place your large data REST call after the check for no input.
In the client controller kick off the REST call by using the ".server.get([Object])" method.
For example you might have a loader indicator in lieu of your map while it's fetching the data and might do something like this:
c.getMapData = function(action) {
c.loadingIndicator = true;
c.server.get({someInput:'inputs'}).then(function(response){
c.loadingIndicator = false;
c.data.map_data = response.data.map_data
})
};
c.getMapData();
Hope this helps