Ola
I have a message BANanoObject that I can execute .RunMethod on. This returns a promise.
Is it possible directly from a class instance that will be compiled into a library, to have the promise execute and then I can only get the result. The result will be a string.
As an example... This call execute code on the BANanoObject. This is a promise call. I have to wait for it to execute so that I can get a result.
Then when I want to get the token string, I can just call
, which will execute the code below on the same class.
Is this possible? If so how do I achieve it? I have ran the code and it returns a promise and not the string. Surely I'm missing something.
Thanks!
I have a message BANanoObject that I can execute .RunMethod on. This returns a promise.
Is it possible directly from a class instance that will be compiled into a library, to have the promise execute and then I can only get the result. The result will be a string.
As an example... This call execute code on the BANanoObject. This is a promise call. I have to wait for it to execute so that I can get a result.
B4X:
private Sub getToken2 As String
'define the vapidKey
Dim opt As Map = CreateMap()
opt.Put("vapidKey", key)
'execute the promise
Dim tThen As Object
Dim tErr As Object
Dim t As BANanoPromise = messaging.RunMethod("getToken", opt)
t.Then(tThen)
BANAno.ReturnThen(tThen)
t.Else(tErr)
BANAno.ReturnThen("")
t.End
End Sub
Then when I want to get the token string, I can just call
B4X:
Dim token As String = instance.getToken
B4X:
Sub getToken As String
Dim fbToken As String = ""
Dim promToken As BANanoPromise
promToken.CallSub(Me, "getToken2", Null)
' will pause your code here
fbToken = BANAno.Await(promToken)
Return fbToken
End Sub
Is this possible? If so how do I achieve it? I have ran the code and it returns a promise and not the string. Surely I'm missing something.
Thanks!
Last edited: