正在等待DONE Job状态 - BigQuery的Dart Client

时间:2014-04-19 20:30:09

标签: dart google-bigquery dart-async

Dart Client for Bigquery是异步的,需要根据下面的Java代码轮询作业状态。 我如何在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);
}

1 个答案:

答案 0 :(得分:1)

这样的东西
Future poll() {
  return new Future.delayed(new Duration(seconds: 1), () => job.getStatus().getState()).then((e) {
    if(e.done) {
      somethingToDoAfterGotState());
    } else {
      return poll();
    }
  });
}

(未经测试)