Hi, 
As part of this Wearable DataLayer library I'm creating there are a few bits that require you to 'wait' for a result. A key example is getting the Connected Nodes (Devices).
The NodeApi has a method getConnectedNodes, but the result isn't instant as it needs to search the nodes. There are 2 options for working with this.
Option 1 - Pending result
example:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Option 2 - Blocking thread (New runnable)
example:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Note these are online examples not the actual code I will use. Now I cannot figure which would be best here. Obviously the best way would be for b4a user to call
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
My understanding of option1 is that I would have to raise another event with the results. So, Would option 2 allow the above technique?
Thanks
			
			As part of this Wearable DataLayer library I'm creating there are a few bits that require you to 'wait' for a result. A key example is getting the Connected Nodes (Devices).
The NodeApi has a method getConnectedNodes, but the result isn't instant as it needs to search the nodes. There are 2 options for working with this.
Option 1 - Pending result
example:
			
				B4X:
			
		
		
		PendingResult<NodeApi.GetConnectedNodesResult> nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient);
            nodes.setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
                @Override
                public void onResult(NodeApi.GetConnectedNodesResult result) {
......//code overwriting Callbacks)
	Option 2 - Blocking thread (New runnable)
example:
			
				B4X:
			
		
		
		    new Thread(new Runnable() {
        @Override
        public void run() {
            client.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
            NodeApi.GetConnectedNodesResult result =
                    Wearable.NodeApi.getConnectedNodes(client).await();
            List<Node> nodes = result.getNodes();
            if (nodes.size() > 0) {
                nodeId = nodes.get(0).getId();
            }
            client.disconnect();
        }
    }).start();
	Note these are online examples not the actual code I will use. Now I cannot figure which would be best here. Obviously the best way would be for b4a user to call
			
				B4X:
			
		
		
		Dim NodeList as List = DataLAyer1.GetNodes
	My understanding of option1 is that I would have to raise another event with the results. So, Would option 2 allow the above technique?
Thanks