The Backendless 5.0 APIs don’t seem to block until the call returns. Instead, they seem to step over to the next line after the closure, here’s an example.
I currently use the login API to login the user and then restore the user info from the Backendless server in the response handler. However, the login call doesn’t block until the response handler is called. Instead, it steps right over, only for the handler to be called later.
That behavior seems like what an asynchronous call would, maybe I am missing something or doing it incorrectly.
I am using Swift 4.2 and on Backendless 5.x btw.
Can someone please clarify? Thanks!
Here is the code snippet:
func loginUser(mobileNumber: String, passcode:String) -> Bool {
var success = true
let backendless = Backendless.shared
backendless.userService.login(identity: mobileNumber, password: passcode, responseHandler: {user in
// CODE TO HANDLE SUCCESSFUL LOGIN GOES HERE
}, errorHandler: {fault in
// ERROR HANDLING CODE HERE
success = false
})
return success
}