phetsims / resistance-in-a-wire

"Resistance in a Wire" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/resistance-in-a-wire
GNU General Public License v3.0
1 stars 4 forks source link

ResistanceInAWireModel is not created on demand #76

Closed pixelzoom closed 8 years ago

pixelzoom commented 8 years ago

ResistanceInAWireScreen constructor looks like this:

  function ResistanceInAWireScreen() {
    var model = new ResistanceInAWireModel();
    Screen.call( this,
      function() { return model; },
      function( model ) { return new ResistanceInAWireScreenView( model ); },
      { backgroundColor: '#ffffdf' }
    );
  }

The model is not supposed to be instantiated by the constructor, it's supposed to be instantiated on demand by Sim.js, when the Screen's createModel function is called. Unless there's a good reason to do things differently in this sim, the constructor should look like this:

  function ResistanceInAWireScreen() {
    Screen.call( this,
      function() { return new ResistanceInAWireModel(); },
      function( model ) { return new ResistanceInAWireScreenView( model ); },
      { backgroundColor: '#ffffdf' }
    );
  }

If there is a legitimate reason why it needs to be different, please document it.

pixelzoom commented 8 years ago

In https://github.com/phetsims/bending-light/issues/356#issuecomment-245826609, @samreid said:

Those problems will interfere with the loading bar (if nothing else), we should address them.

samreid commented 8 years ago

I realized this will not interfere with the current loading bar proposal, but it should still be fixed.

jbphet commented 8 years ago

fixed, closing