lib/js/ComponentView.js
function(connect, callback) {
      callback = callback || function(){};
      var t = this,
          needsConnecting = false,
          logMethod = (connect ? 'connectMonitor' : 'disconnectMonitor'),
          originalParams = null,
          monitor = t.model.get('monitor'),
          isConnected = monitor.isConnected();

      // Determine if we need to connect/disconnect
      if (
          (connect && !isConnected && monitor.get('probeClass')) ||
          (!connect && isConnected)) {
        needsConnecting = true;
      }

      // If no need to connect, callback on next tick.  This makes the
      // call stack consistent regardless of the presence of monitors.
      if (!needsConnecting) {
        log.info(logMethod + '.alreadyConnected', t.logCtxt);
        setTimeout(function(){
          callback(null);
        },0);
        return;
      }

      // If connecting, override the init params with url params
      if (connect) {
        originalParams = monitor.get('initParams');
        monitor.set(
          {initParams: _.extend({}, originalParams, initOverrides)},
          {silent: true}
        );
      }
      else {
        // If disconnecting, remove all change listeners
        monitor.off('change');
      }

      // Connect or disconnect, calling the callback when done
      var connectFn = connect ? 'connect' : 'disconnect';
      log.info(logMethod, t.logCtxt);
      monitor[connectFn](function(error) {

        // Replace original initParams (so the page isn't dirty)
        // Acutal init params will become attributes of the monitor object
        if (originalParams) {
          monitor.set(
            {initParams: originalParams},
            {silent: true}
          );
        }

        // If disconnecting, clear the probe data
        if (!connect) {
          var probeElems = monitor.toProbeJSON();
          delete probeElems.id;
          monitor.set(probeElems, {unset:true});
        }

        // Callback passing error if set
        return callback(error);
      });
    }
function(connect, callback) {
      callback = callback || function(){};
      var t = this,
          needsConnecting = false,
          logMethod = (connect ? 'connectMonitor' : 'disconnectMonitor'),
          originalParams = null,
          monitor = t.model.get('monitor'),
          isConnected = monitor.isConnected();

      // Determine if we need to connect/disconnect
      if (
          (connect && !isConnected && monitor.get('probeClass')) ||
          (!connect && isConnected)) {
        needsConnecting = true;
      }

      // If no need to connect, callback on next tick.  This makes the
      // call stack consistent regardless of the presence of monitors.
      if (!needsConnecting) {
        log.info(logMethod + '.alreadyConnected', t.logCtxt);
        setTimeout(function(){
          callback(null);
        },0);
        return;
      }

      // If connecting, override the init params with url params
      if (connect) {
        originalParams = monitor.get('initParams');
        monitor.set(
          {initParams: _.extend({}, originalParams, initOverrides)},
          {silent: true}
        );
      }
      else {
        // If disconnecting, remove all change listeners
        monitor.off('change');
      }

      // Connect or disconnect, calling the callback when done
      var connectFn = connect ? 'connect' : 'disconnect';
      log.info(logMethod, t.logCtxt);
      monitor[connectFn](function(error) {

        // Replace original initParams (so the page isn't dirty)
        // Acutal init params will become attributes of the monitor object
        if (originalParams) {
          monitor.set(
            {initParams: originalParams},
            {silent: true}
          );
        }

        // If disconnecting, clear the probe data
        if (!connect) {
          var probeElems = monitor.toProbeJSON();
          delete probeElems.id;
          monitor.set(probeElems, {unset:true});
        }

        // Callback passing error if set
        return callback(error);
      });
    }
function ( connect , callback ) { callback = callback || function ( ) { } ; var t = this , needsConnecting = false , logMethod = ( connect ? 'connectMonitor' : 'disconnectMonitor' ) , originalParams = null , monitor = t . model . get ( 'monitor' ) , isConnected = monitor . isConnected ( ) ; // Determine if we need to connect/disconnect if ( ( connect && ! isConnected && monitor . get ( 'probeClass' ) ) || ( ! connect && isConnected ) ) { needsConnecting = true ; } // If no need to connect, callback on next tick.  This makes the // call stack consistent regardless of the presence of monitors. if ( ! needsConnecting ) { log . info ( logMethod + '.alreadyConnected' , t . logCtxt ) ; setTimeout ( function ( ) { callback ( null ) ; } , 0 ) ; return ; } // If connecting, override the init params with url params if ( connect ) { originalParams = monitor . get ( 'initParams' ) ; monitor . set ( { initParams : _ . extend ( { } , originalParams , initOverrides ) } , { silent : true } ) ; } else { // If disconnecting, remove all change listeners monitor . off ( 'change' ) ; } // Connect or disconnect, calling the callback when done var connectFn = connect ? 'connect' : 'disconnect' ; log . info ( logMethod , t . logCtxt ) ; monitor [ connectFn ] ( function ( error ) { // Replace original initParams (so the page isn't dirty) // Acutal init params will become attributes of the monitor object if ( originalParams ) { monitor . set ( { initParams : originalParams } , { silent : true } ) ; } // If disconnecting, clear the probe data if ( ! connect ) { var probeElems = monitor . toProbeJSON ( ) ; delete probeElems . id ; monitor . set ( probeElems , { unset : true } ) ; } // Callback passing error if set return callback ( error ) ; } ) ; }
Connect or disconnect the monitor, calling the callback when done.

@method connectMonitor
@param connect {boolean} Connect if true, disconnect if false
@param callback(error)
Connect or disconnect the monitor calling the callback when done .