message: Fix `doLater()` to respect the `msec` param.
diff: @@ -31,16 +31,24 @@ function doLaterTimeoutHandler(): void {
  *
  * @param func the function to be executed later
  * @param msec Optional time delay in ms. Default is 0.
  + * @param hiPrio If true, then the function will be called before other scheduled functions.
  + * This only applies if `msec` is 0.
  * @return {LaterHandle} This object can be used to cancel the scheduled execution.
  */
  -export function doLater(func: Function, msec=0): Disposable {
  +export function doLater(func: Function, msec=0, hiPrio=false): Disposable {
  + if (msec === 0) {
  + // Zero delay calls are batched to use one timer because they are so common.
  const doLaterFunction: DoLaterFunctionEntry = {
  func
  };
  + if (hiPrio) {
  + laterList.splice(0,0, doLaterFunction);
  + } else {
  laterList.push(doLaterFunction);
  + }
  if (doLaterId == null) {
  - doLaterId = setTimeout(doLaterTimeoutHandler, msec);
  + doLaterId = setTimeout(doLaterTimeoutHandler, 0);
  }
  return {
  @@ -48,6 +56,22 @@ export function doLater(func: Function, msec=0): Disposable {
  doLaterFunction.func = null;
  }
  };
  + } else {
  +
  + // Non-zero timeouts have to get their own timer.
  + let execFunction = func;
  + window.setTimeout(() => {
  + if (execFunction != null) {
  + execFunction();
  + }
  + }, msec);
  +
  + return {
  + dispose: () => {
  + execFunction = null;
  + }
  + };
  + }
  }
  let doLaterFrameId: number = -1;
  