B2G/gecko/services/sync/tps/extensions/tps/modules/tps.jsm
/**
   * Synchronously wait for the named event to be observed.
   *
   * When the event is observed, the function will wait an extra tick before
   * returning.
   *
   * @param name
   *        String event to wait for.
   */
Synchronously wait for the named event to be observed.
When the event is observed, the function will wait an extra tick before
returning.

@param name
String event to wait for.
Synchronously wait for the named event to be observed . When the event is observed the function will wait an extra tick before returning . @param name String event to wait for .
function waitForEvent(name) {
    Logger.logInfo("Waiting for " + name + "...");
    let cb = Async.makeSpinningCallback();
    Svc.Obs.add(name, cb);
    cb.wait();
    Svc.Obs.remove(name, cb);
    Logger.logInfo(name + " observed!");
    let cb = Async.makeSpinningCallback();
    Utils.nextTick(cb);
    cb.wait();
  }
function waitForEvent ( name ) { Logger . logInfo ( "Waiting for " + name + "..." ) ; let cb = Async . makeSpinningCallback ( ) ; Svc . Obs . add ( name , cb ) ; cb . wait ( ) ; Svc . Obs . remove ( name , cb ) ; Logger . logInfo ( name + " observed!" ) ; let cb = Async . makeSpinningCallback ( ) ; Utils . nextTick ( cb ) ; cb . wait ( ) ; }
Synchronously wait for the named event to be observed.
Synchronously wait for the named event to be observed .