- Format codes
This commit is contained in:
@@ -5,7 +5,7 @@ local _Request =
|
||||
command="",
|
||||
currentTime=0,
|
||||
timeOut=2,
|
||||
id = '0'
|
||||
id='0',
|
||||
}
|
||||
local __defaultErrorFunction=nil
|
||||
local isDebugActive=false
|
||||
@@ -31,9 +31,9 @@ end
|
||||
|
||||
--The call will store in the webDB the return value from the function passed
|
||||
--it timeouts
|
||||
local function retrieveJS(funcToCall, id)
|
||||
local function retrieveJS(funcToCall,filename)
|
||||
--Used for retrieveData function
|
||||
JS.callJS("FS.writeFile('"..love.filesystem.getSaveDirectory().."/__temp"..id.."', "..funcToCall..");")
|
||||
JS.callJS(("FS.writeFile('%s/%s',%s);"):format(love.filesystem.getSaveDirectory(),filename,funcToCall))
|
||||
end
|
||||
|
||||
--Call JS.newRequest instead
|
||||
@@ -43,23 +43,26 @@ function _Request:new(isPromise, command, onDataLoaded, onError, timeout, id)
|
||||
obj.command=command
|
||||
obj.onError=onError or __defaultErrorFunction
|
||||
if not isPromise then
|
||||
retrieveJS(command, id)
|
||||
retrieveJS(command, self.filename)
|
||||
else
|
||||
JS.callJS(command)
|
||||
end
|
||||
obj.onDataLoaded=onDataLoaded
|
||||
obj.timeOut=(timeout==nil) and obj.timeOut or timeout
|
||||
obj.id=id
|
||||
obj.filename="__temp"..id
|
||||
|
||||
|
||||
function obj:getData()
|
||||
--Try to read from webdb
|
||||
return love.filesystem.read("__temp"..self.id)
|
||||
if love.filesystem.getInfo(self.filename) then
|
||||
return love.filesystem.read(self.filename)
|
||||
end
|
||||
end
|
||||
|
||||
function obj:purgeData()
|
||||
--Data must be purged for not allowing old data to be retrieved
|
||||
love.filesystem.remove("__temp"..self.id)
|
||||
love.filesystem.remove(self.filename)
|
||||
end
|
||||
|
||||
function obj:update(dt)
|
||||
|
||||
Reference in New Issue
Block a user