I am currently adapting a desktop & webapp to an iOS App.
Of course, because of the new framework everything has to be written from scratch, but the API used to access the database will still be used.
In the desktop and webapp most API calls were done synchronously so a class function loading and processing some data would basically look like this:
Dim jsResult as JSONItem Dim processedString As String //mySocket is a httpSocket //the Query function synchronously sends a GET request and returns a JSONItem jsResult = mySocket.Query("someURL") //Do something with jsResult processedString = jsResult.value("something") jsResult = mySocket.Query("someOtherURL") //Do something with jsResult processedString = processedString + jsResult.value("somethingElse") //End of loading, return the processed String value Return processedString
Now that xojo.net.HTTPSocket only works asynchronously I have one function to setup all HTTPSocket queries
and use a callback delegate to process each response.
What would be the best practice to wait for all queries to be performed and then return a dictionary or a processed string Value ?
Side note: the downfall of the above code is that it can lock up the Application if the query takes too long.
As soon as the iOS app is ready, the desktop and WebApps will be updated to use asynchronous queries.