// Copyright 2018-2019, University of Colorado Boulder

/**
 * View that typically connects a sensor (like a ProbeNode) to its body (where the readout value or chart appears).
 *
 * @author Sam Reid (PhET Interactive Simulations)
 */
define( require => {
  'use strict';

  // modules
  const inherit = require( 'PHET_CORE/inherit' );
  const merge = require( 'PHET_CORE/merge' );
  const Path = require( 'SCENERY/nodes/Path' );
  const Property = require( 'AXON/Property' );
  const sceneryPhet = require( 'SCENERY_PHET/sceneryPhet' );
  const Shape = require( 'KITE/Shape' );

  /**
   * @param {Property.<Vector2>} position1Property - connects to one object
   * @param {Property.<Vector2>} normal1Property - defines the control point of the cubic curve, relative to the position1
   * @param {Property.<Vector2>} position2Property - connects to another object
   * @param {Property.<Vector2>} normal2Property - defines the control point of the cubic curve, relative to the position2
   * @param {Object} [options]
   * @constructor
   */
  function WireNode( position1Property, normal1Property, position2Property, normal2Property, options ) {

    options = merge( {
      stroke: 'black'
    }, options );

    const self = this;
    Path.call( this, null, options );

    // @private
    this.multilink = Property.multilink( [
      position1Property, normal1Property, position2Property, normal2Property
    ], function( position1, normal1, position2, normal2 ) {
      self.shape = new Shape()
        .moveToPoint( position1 )
        .cubicCurveToPoint(
          position1.plus( normal1 ),
          position2.plus( normal2 ),
          position2
        );
    } );
  }

  sceneryPhet.register( 'WireNode', WireNode );

  return inherit( Path, WireNode, {

    /**
     * Unlink listeners when disposed.
     * @public
     */
    dispose: function() {
      this.multilink.dispose();
    }
  } );
} );
// Copyright 2018-2019, University of Colorado Boulder

/**
 * View that typically connects a sensor (like a ProbeNode) to its body (where the readout value or chart appears).
 *
 * @author Sam Reid (PhET Interactive Simulations)
 */
define( require => {
  'use strict';

  // modules
  const inherit = require( 'PHET_CORE/inherit' );
  const merge = require( 'PHET_CORE/merge' );
  const Path = require( 'SCENERY/nodes/Path' );
  const Property = require( 'AXON/Property' );
  const sceneryPhet = require( 'SCENERY_PHET/sceneryPhet' );
  const Shape = require( 'KITE/Shape' );

  /**
   * @param {Property.<Vector2>} position1Property - connects to one object, often this is a DerivedProperty
   * @param {Property.<Vector2>} normal1Property - defines the control point of the cubic curve, relative to the position1
   * @param {Property.<Vector2>} position2Property - connects to another object, often this is a DerivedProperty
   * @param {Property.<Vector2>} normal2Property - defines the control point of the cubic curve, relative to the position2
   * @param {Object} [options]
   * @constructor
   */
  function WireNode( position1Property, normal1Property, position2Property, normal2Property, options ) {

    options = merge( {
      stroke: 'black'
    }, options );

    Path.call( this, null, options );

    // @private
    this.multilink = Property.multilink( [
      position1Property, normal1Property, position2Property, normal2Property
    ], ( position1, normal1, position2, normal2 ) => {
      this.shape = new Shape()
        .moveToPoint( position1 )
        .cubicCurveToPoint(
          position1.plus( normal1 ),
          position2.plus( normal2 ),
          position2
        );
    } );
  }

  sceneryPhet.register( 'WireNode', WireNode );

  return inherit( Path, WireNode, {

    /**
     * Unlink listeners when disposed.
     * @public
     */
    dispose: function() {
      this.multilink.dispose();
    }
  } );
} );
Convert to arrow+this, add docs, see https://github.com/phetsims/circuit-construction-kit-common/issues/531