Skip to content

Commit

Permalink
Dynamically load values instead of caching, see #210
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisklus committed Jan 9, 2019
1 parent 6c959fa commit 5803749
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions js/Multilink.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ define( function( require ) {

this.dependencies = dependencies; // @private

// @private Keep track of each dependency and only update the changed value, for speed
this.dependencyValues = dependencies.map( function( property ) {return property.get();} );

var self = this;

// @private Keep track of listeners so they can be detached
Expand All @@ -39,8 +36,7 @@ define( function( require ) {

// don't call listener if this Multilink has been disposed, see https://github.com/phetsims/axon/issues/192
if ( !self.isDisposed ) {
self.dependencyValues[ i ] = value;
callback.apply( null, self.dependencyValues );
callback.apply( null, dependencies.map( function( property ) {return property.get();} ) );
}
};
self.dependencyListeners.push( listener );
Expand All @@ -49,7 +45,7 @@ define( function( require ) {

//Send initial call back but only if we are non-lazy
if ( !lazy ) {
callback.apply( null, this.dependencyValues );
callback.apply( null, dependencies.map( function( property ) {return property.get();} ) );
}

// @private - whether the Multilink has been disposed
Expand All @@ -73,7 +69,6 @@ define( function( require ) {
}
this.dependencies = null;
this.dependencyListeners = null;
this.dependencyValues = null;
this.isDisposed = true;
}
} );
Expand Down

0 comments on commit 5803749

Please sign in to comment.