I am trying to make use an existing class which returns the data in the form of callback. The call is like this-
class Validator{
validate(){
DataProvider.getInstance(new DataListener(){
@Override
void onDataReady(String data){
//Do something with data
}
});
}
return //data when the above call is finished
}
I want a clean way to return the data which should be returned when the async call is completed. Putting a while loop and checking for data is an obvious but un-clean way. Can I achieve this using RxJava?
Note: It's ok for the validate function to wait if the call takes time