B4J Question EvalWithResult & Promises [SOLVED]

ilan

Expert
Licensed User
Longtime User
It should be done in the JavaScript itself. You might need to call b4j_raiseEvent to raise a server event from the "then" function.

it was simpler than i thought ?

js code:

B4X:
ws.Eval($"getIPs().then(res => {b4j_raiseEvent("get_public_ip",{res});});"$,Null)

b4j event:

B4X:
Sub get_public_ip(Params As Map)
    If Params.ContainsKey("res") Then 
        Dim l As List = Params.Get("res")
        For i = 0 To l.Size-1
            Log(l.Get(i))
        Next        
    End If
End Sub

public ip cdn:

B4X:
<script src="https://cdn.jsdelivr.net/gh/joeymalvinni/webrtc-ip/dist/bundle.dev.js"></script>

thanx ?
 
Last edited:
Upvote 0
Top