Skip to content

Commit

Permalink
implemented PlaceThePointsNode.dispose #78
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Apr 23, 2017
1 parent 8b1101d commit 138e56f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions js/linegame/view/PlaceThePointsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ define( function( require ) {
GraphTheLineNode.call( this, challenge, model, challengeSize, audioPlayer );

var self = this;
//TODO #78 unlink in dispose
model.playStateProperty.link( function( playState ) {

var playStateObserver = function( playState ) {

// show user's line only in states where there guess is wrong.
self.graphNode.setGuessVisible(
Expand All @@ -42,13 +42,25 @@ define( function( require ) {
*/
self.graphNode.setAnswerPointVisible( playState === PlayState.NEXT && !challenge.isCorrect() );
self.graphNode.setGuessPointVisible( false );
} );
};
model.playStateProperty.link( playStateObserver ); // unlink in dispose

// @private called by dispose
this.disposePlaceThePointsNode = function() {
model.playStateProperty.unlink( playStateObserver );
};
}

graphingLines.register( 'PlaceThePointsNode', PlaceThePointsNode );

return inherit( GraphTheLineNode, PlaceThePointsNode, {

// @public
dispose: function() {
this.disposePlaceThePointsNode();
GraphTheLineNode.prototype.dispose.call( this );
},

/**
* Creates the graph portion of the view.
* @param {Challenge} challenge
Expand Down

0 comments on commit 138e56f

Please sign in to comment.