Help needed with TSNet and optimization
Posted: Wed Jan 18, 2017 10:24 am
I'm in the final stages of testing my iOS App which uses a REST API to download live data once every second or so. The data expires after the screen updates. I've realized that PUT is synchronous so I'm hoping to speed things up and stop the occasional screen freezing by going the asynchronous route, but I don't understand how the TSNET library and commands work. Here's what I've done so far.
So I guess the main question is should I stick with my second approach, assuming the code is correct or further optimize with TSNet - but how?
thx in advance.
Code: Select all
--original code (only needed three lines) but is synchronous
on mouseUp
put "http://"&tikipp&"/urlsample/" into talldata
put URL talldata into talldata
put jsonimport(talldata) into gArray
end mouseUp
---replaced by asynchronous approach:
on mouseUp
put "http://"&tikipp&"/urlsample/" into talldata
load URL talldata with message "downloadComplete"
end mouseUP
on downloadComplete pURL, pURLStatus
if pURLStatus is "cached" then
put URL pURL into talldata2
put jsonimport(talldata2) into gArray
end if
unload url pURL
end downloadComplete
------
thx in advance.