I am trying to write a mock log in while developing my app so I don’t have to actually ping my servers. I wanted to delay the log in to make it look like it was waiting for a response from the server. For some reason, the M:logInUser function is returning immediately and doesn’t return the true/false like I was expecting.
Is there an error with the performWithDelay that is keeping it from delaying? Also, does the callback function not return the boolean? Any help would be greatly appreciated.
local function mockLogIn( email, pass ) for \_, user in ipairs(mockUsers.data) do if (email == user.email and pass == user.password) then return true end end return false end function dataService:logInUser( email, pass ) return timer.performWithDelay( 2000, mockLogIn(email, pass)) end
In my calling function I am doing this, but it is printing nil:
local function checkLogin( email, password ) local temp = dataService:logInUser( email, password ) timer.performWithDelay( 4000, print(temp) ) end