Android Question [solved] WaitFor and PutMapAsync ?

svanneste

Member
Licensed User
Hi,
Please how to use Wait For with KVS.PutMapAsync ? I can not find how to write it (below attached what I thought I had to write). Thanks
B4X:
    Dim kvs1 As KeyValueStore
    kvs1.Initialize(File.DirApp,"users") 'Example played on B4J
    kvs1.PutMapAsync(CreateMap("U1":"p1","U2":"p2","U3":"p3"))
    Wait For(kvs1) kvs1_Terminated(kvs1 As KeyValueStore)
    Log("Finished")
    kvs1.Close
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It was missing in the internal documentation. I will add it.

It should be:
B4X:
Wait For (kvs1.PutMapAsync(CreateMap("U1":"P1","U2":"p2","U3":"p3"))) Complete (Success As Boolean)

1601628132086.png


Is there any way to find the events without searching the forums ? Thanks
There are two types of "events" that can be caught with Wait For:

1. Regular events where Wait For is an alternative to an event sub. There are many ways to see these events signatures and the best one is to write space followed by tab.

2. [B4X] Resumable subs that return values (ResumableSub) . This is the case here. The event name will always be Complete, and it has a single parameter. The compiler doesn't know the parameter type so it must be documented.
 
Last edited:
Upvote 0
Top