method asyncTimer


Timer asyncTimer(void method(), Duration timeout)

Invokes a function asynchronously. This will call Polymer.flush() and then return a new Timer with the provided method and timeout.

If you would prefer to run the callback using window.requestAnimationFrame, see the async method.

To cancel, call Timer.cancel on the result of this method.

Source

Timer asyncTimer(void method(), Duration timeout) {
  // Dart note: "async" is split into 2 methods so it can have a sensible type
  // signatures. Also removed the various features that don't make sense in a
  // Dart world, like binding to "this" and taking arguments list.

  // when polyfilling Object.observe, ensure changes
  // propagate before executing the async method
  scheduleMicrotask(Observable.dirtyCheck);
  PolymerJs.flush(); // for polymer-js interop
  return new Timer(timeout, method);
}