Wish OkHttp - Ability to specify separate JobDone functions for separate jobs

klarsys

Active Member
Licensed User
Longtime User
It will be great to be able to specify JobDone function as an argument while initialising, so that code for different types of jobs can be kept separate.

Also, if a 'tag' can be passed as an argument, which is passed as it is to the JobDone function (for context).
 

klarsys

Active Member
Licensed User
Longtime User
How about this change:


B4X:
Private targetSub As String = "JobDone"

'Initializes the Job.
'Name - The job's name. Note that the name doesn't need to be unique.
'TargetModule - The activity or service that will handle the JobDone event.
'TargetFunction - The function to be called to handle the JobDone event.
Public Sub Initialize2 (Name As String, TargetModule As Object, TargetFunction As String)
    JobName = Name
    target = TargetModule
    targetSub = TargetFunction
End Sub

'Called by the service when job completes
Public Sub Complete (id As Int)
    taskId = id
    CallSubDelayed2(target, targetSub, Me)
End Sub
 

klarsys

Active Member
Licensed User
Longtime User
Well, Initialize2 did not work, but following worked:


B4X:
Public Sub setOnComplete(OnComplete As String)
    targetSub = OnComplete
End Sub
Public Sub getOnComplete As String
    Return targetSub
End Sub

Request to add this in mainstream library. It is backwards compatible.
 
Top