phetsims / neuron

"Neuron" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 3 forks source link

Use an event instead of toggling a property to trigger redraws of the particles #67

Closed jbphet closed 9 years ago

jbphet commented 9 years ago

Currently, the model code is toggling a property for the purpose of signaling the view code that a redraw of the particles canvas needs to be performed. It would be better to use an event.

Code snippet from model:

      //invert the value and trigger change event
      this.particlesStateChangedProperty.set( !this.particlesStateChangedProperty.get() );

Code snippet from view (ParticlesCanvasNode):

    // if during a step we change, then trigger a repaint
    //Use Particles Canvas Node to render all the particles directly
    neuronModel.particlesStateChangedProperty.link( function( newValue ) {
      thisNode.invalidatePaint();
    } );