Skip to content

Commit

Permalink
fix no-this-alias, phetsims/chipper#1223
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Apr 14, 2022
1 parent 579959c commit a2258b1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions js/buttons/ButtonModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,9 @@ export default class ButtonModel extends EnabledComponent {
looksPressedProperties.push( this.downProperty );

// assign a new Multilink (for disposal), and make sure that the button looks pressed when any of the
// PressListeners created by this ButtonModel look pressed. Note that this cannot be an arrow function
// because its implementation relies on arguments.
const self = this;
// PressListeners created by this ButtonModel look pressed.
this.looksPressedMultilink = Property.multilink( looksPressedProperties, ( ...args: boolean[] ) => {
self.looksPressedProperty.value = _.reduce( args, ( sum: boolean, newValue: boolean ) => sum || newValue, false );
this.looksPressedProperty.value = _.reduce( args, ( sum: boolean, newValue: boolean ) => sum || newValue, false );
} );

const looksOverProperties = this.listeners.map( listener => listener.looksOverProperty );
Expand All @@ -211,7 +209,7 @@ export default class ButtonModel extends EnabledComponent {
// PressListeners created by this ButtonModel look over. Note that this cannot be an arrow function
// because its implementation relies on arguments.
this.looksOverMultilink = Property.multilink( looksOverProperties, ( ...args: boolean[] ) => {
self.looksOverProperty.value = _.reduce( args, ( sum: boolean, newValue: boolean ) => sum || newValue, false );
this.looksOverProperty.value = _.reduce( args, ( sum: boolean, newValue: boolean ) => sum || newValue, false );
} );

return pressListener;
Expand Down

0 comments on commit a2258b1

Please sign in to comment.