positionService.call(new PositionCallback(){ onPositionUpdate(Position position)
{
this.position=position;
if (isLoaded){
refreshDataWithPosition();
}
});
dataService.call(new DataCallback(){ onDataUpdate(Data data)
{
//does this need synchronization?
updateTable(data,position);
isLoaded=true;
});
I have the following code above. It loads the GPS geolocation position and all some data at the same time. If the GPS data updates first updateTable will update taking this into account. If the GPS data updates second it will call refreshDataWithPosition to refresh its contents. I want to updateTable with or without position for a more responsive experience.
How does the GWT async callback work with single threading (or possibly a multithreaded javascript engine)? The danger here is the position callback gets called after updateTable finishes but before isLoaded is set to true. In this scenario the table won't be refreshed with the position data.