The Dart Client for Bigquery is async, one needs to poll for job state as per the Java code below. How can I achieve same in Dart?
//Java Equivalent
Job job = bigquery.jobs().insert(PROJECT_ID, runJob).execute();
String status = job.getStatus().getState();
while(!status.equalsIgnoreCase("DONE")) {
status = bigquery.jobs().get(PROJECT_ID, job.getId()).execute().getStatus().getState();
System.out.println("Status: " + status);
Thread.wait(1000);
}
Something like
Future poll() {
return new Future.delayed(new Duration(seconds: 1), () => job.getStatus().getState()).then((e) {
if(e.done) {
somethingToDoAfterGotState());
} else {
return poll();
}
});
}
(not tested)