Let's say I have this code:
So basically I'm doing something that can result in one of two events in the end, either the ResponseSuccess or the ResponseError.
Considering that we use a single event signature in the Wait For, how can I use a resumable sub in this scenario and handle two possible events?
B4X:
Sub Class_Globals
Private http_client As OkHttpClient
End Sub
Public Sub Initialize (req As OkHttpRequest, taskId as int)
http_client.Initialize("http_client")
http_client.Execute(req, taskId)
End Sub
Sub http_client_ResponseSuccess (Response As OkHttpResponse, ResponseTaskId As Int)
ToastMessageShow("Success", False)
End Sub
Sub http_client_ResponseError (Response As OkHttpResponse, Reason As String, ResponseStatusCode As Int, ResponseTaskId As Int)
ToastMessageShow("Error: " & Reason, False)
End Sub
So basically I'm doing something that can result in one of two events in the end, either the ResponseSuccess or the ResponseError.
Considering that we use a single event signature in the Wait For, how can I use a resumable sub in this scenario and handle two possible events?