src/Javascript/Mozilla/old_snapshots/sync/modules/util.js
/**
   * Wrap functions to notify when it starts and finishes executing or if it
   * threw an error.
   *
   * The message is a combination of a provided prefix, the local name, and
   * the event. Possible events are: "start", "finish", "error". The subject
   * is the function's return value on "finish" or the caught exception on
   * "error". The data argument is the predefined data value.
   *
   * Example:
   *
   * @usage function MyObj(name) {
   *          this.name = name;
   *          this._notify = Utils.notify("obj:");
   *        }
   *        MyObj.prototype = {
   *          foo: function() this._notify("func", "data-arg", function () {
   *            //...
   *          }(),
   *        };
   */
Wrap functions to notify when it starts and finishes executing or if it
threw an error.

The message is a combination of a provided prefix, the local name, and
the event.




Wrap functions to notify when it starts and finishes executing or if it threw an error . The message is a combination of a provided prefix the local name and the event .
function Utils_notify(prefix) {
    return function NotifyMaker(name, data, func) {
      let thisArg = this;
      let notify = function(state, subject) {
        let mesg = prefix + name + ":" + state;
        thisArg._log.trace("Event: " + mesg);
        Observers.notify(mesg, subject, data);
      };
      return function WrappedNotify() {
        try {
          notify("start", null);
          let ret = func.call(thisArg);
          notify("finish", ret);
          return ret;
        }
        catch(ex) {
          notify("error", ex);
          throw ex;
        }
      };
    };
  }
function Utils_notify ( prefix ) { return function NotifyMaker ( name , data , func ) { let thisArg = this ; let notify = function ( state , subject ) { let mesg = prefix + name + ":" + state ; thisArg . _log . trace ( "Event: " + mesg ) ; Observers . notify ( mesg , subject , data ) ; } ; return function WrappedNotify ( ) { try { notify ( "start" , null ) ; let ret = func . call ( thisArg ) ; notify ( "finish" , ret ) ; return ret ; } catch ( ex ) { notify ( "error" , ex ) ; throw ex ; } } ; } ; }
Wrap functions to notify when it starts and finishes executing or if it
 threw an error.
Wrap functions to notify when it starts and finishes executing or if it threw an error .