<commit_before>// Copyright 2015, University of Colorado Boulder

/**
 *
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var inherit = require( 'PHET_CORE/inherit' );
  var ScreenView = require( 'JOIST/ScreenView' );
  var Property = require( 'AXON/Property' );
  var HSlider = require( 'SUN/HSlider' );
  var ABSwitch = require( 'SUN/ABSwitch' );
  var Text = require( 'SCENERY/nodes/Text' );

  var sun = require( 'SUN/sun' );

  function ComponentHolder( createFunction ) {
    var componentHolder = this;
    this.dispose = function() {
      componentHolder.instance.dispose();
    };
    this.create = function() {
      componentHolder.instance = createFunction();
    };
  }

  var numberProperty = new Property( 0 );
  var booleanProperty = new Property( false );

  var components = [
    new ComponentHolder( function() {
      return new HSlider( numberProperty, { min: 0, max: 10 } );
    } ),
    new ComponentHolder( function() {
      return new ABSwitch( booleanProperty, true, new Text( 'true' ), false, new Text( 'false' ) );
    } )
  ];

  function MemoryTestsView() {
    ScreenView.call( this );
  }

  sun.register( 'MemoryTestsView', MemoryTestsView );

  return inherit( ScreenView, MemoryTestsView, {
    step: function() {

      for ( var i = 0; i < components.length; i++ ) {
        var holder = components[ i ];
        holder.instance && this.removeChild( holder.instance );
        holder.instance && holder.dispose();

        holder.create();
        this.addChild( holder.instance );
      }
      console.log( 'create' );
    }
  } );<commit_msg>Added docs, see https://github.com/phetsims/scenery-phet/issues/234<commit_after>// Copyright 2015, University of Colorado Boulder

/**
 *
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var inherit = require( 'PHET_CORE/inherit' );
  var ScreenView = require( 'JOIST/ScreenView' );
  var Property = require( 'AXON/Property' );
  var HSlider = require( 'SUN/HSlider' );
  var ABSwitch = require( 'SUN/ABSwitch' );
  var Text = require( 'SCENERY/nodes/Text' );

  var sun = require( 'SUN/sun' );

  function ComponentHolder( createFunction ) {
    var componentHolder = this;
    this.dispose = function() {
      componentHolder.instance.dispose();
    };
    this.create = function() {
      componentHolder.instance = createFunction();
    };
  }

  var numberProperty = new Property( 0 );
  var booleanProperty = new Property( false );

  var components = [
    new ComponentHolder( function() {
      return new HSlider( numberProperty, { min: 0, max: 10 } );
    } ),
    new ComponentHolder( function() {
      return new ABSwitch( booleanProperty, true, new Text( 'true' ), false, new Text( 'false' ) );
    } )
  ];

  function MemoryTestsView() {
    ScreenView.call( this );
  }

  sun.register( 'MemoryTestsView', MemoryTestsView );

  return inherit( ScreenView, MemoryTestsView, {
    step: function() {

      for ( var i = 0; i < components.length; i++ ) {
        var holder = components[ i ];

        // dispose first, then remove so they will be visible on the screen during animation.
        holder.instance && this.removeChild( holder.instance );
        holder.instance && holder.dispose();

        holder.create();
        this.addChild( holder.instance );
      }
      console.log( 'create' );
    }
  } );
{'fraction_non_alphanumeric': 0.13619240799768184, 'fraction_numerical': 0.006085192697768763, 'mean_word_length': 2.9451428571428573, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6784193', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1020, 'n_words': 279}