I would like to check whether is it possible to be done in B4A?
I would like to pass in different object into a common B4X Library function for HttpJob I created as below.
Then the result will pass to each object function to process the result. Is this approach can be achieve in B4X or is there any alternative way to achieve this?
Thanks in advance.
B4X:
Sub startJob(obj As Object)
Dim j As HttpJob
j.Initialize("", Me) 'name is empty as it is no longer needed
j.Tag = obj
j.PostString("http://x.sss.com/api/Test",body)
j.GetRequest.SetContentType("application/json")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
obj = j.Tag
obj.ParseJSON(j.GetString) 'here different object function will process the result'
End If
j.Release
End Sub
This cannot work as Type Object will not be recognised as having a ParseJSON method. You would need to assign the Object instance to a variable of the correct type to access its ParseJSON method. You can check the type of an Object instance using the IS keyword.
Then the result will pass to each object function to process the result. Is this approach can be achieve in B4X or is there any alternative way to achieve this?