Skip to content

Commit

Permalink
rename scenery listener Emitters suffix to Action suffix, phetsims/ax…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed May 1, 2019
1 parent 68afbff commit 584f783
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
24 changes: 12 additions & 12 deletions js/input/SimpleDragHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ define( function( require ) {
this.lastInterruptedTouchPointer = null;

// @private
this.dragStartedEmitter = new Action( function( point, event ) {
this.dragStartedAction = new Action( function( point, event ) {

if ( self.dragging ) { return; }

Expand Down Expand Up @@ -121,7 +121,7 @@ define( function( require ) {

sceneryLog && sceneryLog.InputListener && sceneryLog.pop();
}, {
tandem: options.tandem.createTandem( 'dragStartedEmitter' ),
tandem: options.tandem.createTandem( 'dragStartedAction' ),

phetioType: ActionIO(
[ { name: 'point', type: Vector2IO, documentation: 'the position of the drag start in view coordinates' },
Expand All @@ -134,7 +134,7 @@ define( function( require ) {
} );

// @private
this.draggedEmitter = new Action( function( point, event ) {
this.draggedAction = new Action( function( point, event ) {

if ( !self.dragging || self.isDisposed ) { return; }

Expand Down Expand Up @@ -177,7 +177,7 @@ define( function( require ) {
sceneryLog && sceneryLog.InputListener && sceneryLog.pop();
}, {
phetioHighFrequency: true,
tandem: options.tandem.createTandem( 'draggedEmitter' ),
tandem: options.tandem.createTandem( 'draggedAction' ),

phetioType: ActionIO(
[ { name: 'point', type: Vector2IO, documentation: 'the position of the drag in view coordinates' },
Expand All @@ -190,7 +190,7 @@ define( function( require ) {
} );

// @private
this.dragEndedEmitter = new Action( function( point, event ) {
this.dragEndedAction = new Action( function( point, event ) {

if ( !self.dragging ) { return; }

Expand All @@ -214,7 +214,7 @@ define( function( require ) {

sceneryLog && sceneryLog.InputListener && sceneryLog.pop();
}, {
tandem: options.tandem.createTandem( 'dragEndedEmitter' ),
tandem: options.tandem.createTandem( 'dragEndedAction' ),

phetioType: ActionIO(
[ { name: 'point', type: Vector2IO, documentation: 'the position of the drag end in view coordinates' },
Expand Down Expand Up @@ -297,7 +297,7 @@ define( function( require ) {

// mouse/touch move
move: function( event ) {
self.draggedEmitter.emit( event.pointer.point, event );
self.draggedAction.execute( event.pointer.point, event );
}
};
PhetioObject.call( this, options );
Expand All @@ -316,14 +316,14 @@ define( function( require ) {
assert && assert( 'illegal call to set dragging on SimpleDragHandler' );
},
startDrag: function( event ) {
this.dragStartedEmitter.emit( event.pointer.point, event );
this.dragStartedAction.execute( event.pointer.point, event );
},

endDrag: function( event ) {

// Signify drag ended. In the case of programmatically ended drags, signify drag ended at 0,0.
// see https://github.com/phetsims/ph-scale-basics/issues/43
this.dragEndedEmitter.emit( event ? event.pointer.point : Vector2.ZERO, event );
this.dragEndedAction.execute( event ? event.pointer.point : Vector2.ZERO, event );
},

// Called when input is interrupted on this listener, see https://github.com/phetsims/scenery/issues/218
Expand Down Expand Up @@ -415,9 +415,9 @@ define( function( require ) {
this.isDraggingProperty.dispose();

// It seemed without disposing these led to a memory leak in Energy Skate Park: Basics
this.dragEndedEmitter.dispose();
this.draggedEmitter.dispose();
this.dragStartedEmitter.dispose();
this.dragEndedAction.dispose();
this.draggedAction.dispose();
this.dragStartedAction.dispose();

PhetioObject.prototype.dispose.call( this );

Expand Down
8 changes: 4 additions & 4 deletions js/listeners/DragListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ define( function( require ) {
this._lastInterruptedTouchPointer = null;

// @private {Emitter} - emitted on drag. Used for triggering phet-io events to the data stream, see https://github.com/phetsims/scenery/issues/842
this._draggedEmitter = new Action( function( event ) {
this._draggedAction = new Action( function( event ) {

// This is done first, before the drag listener is called (from the prototype drag call)
if ( !self._globalPoint.equals( self.pointer.point ) ) {
Expand All @@ -194,7 +194,7 @@ define( function( require ) {
PressListener.prototype.drag.call( self, event );
}, {
phetioFeatured: options.phetioFeatured,
tandem: options.tandem.createTandem( 'draggedEmitter' ),
tandem: options.tandem.createTandem( 'draggedAction' ),
phetioHighFrequency: true,
phetioDocumentation: 'Emits whenever a drag occurs with an EventIO argument.',
phetioReadOnly: options.phetioReadOnly,
Expand Down Expand Up @@ -305,7 +305,7 @@ define( function( require ) {
sceneryLog && sceneryLog.InputListener && sceneryLog.InputListener( 'DragListener drag' );
sceneryLog && sceneryLog.InputListener && sceneryLog.push();

this._draggedEmitter.emit( event );
this._draggedAction.execute( event );

sceneryLog && sceneryLog.InputListener && sceneryLog.pop();
},
Expand Down Expand Up @@ -670,7 +670,7 @@ define( function( require ) {
sceneryLog && sceneryLog.InputListener && sceneryLog.InputListener( 'DragListener dispose' );
sceneryLog && sceneryLog.InputListener && sceneryLog.push();

this._draggedEmitter.dispose();
this._draggedAction.dispose();

this.detachTransformTracker();

Expand Down
36 changes: 18 additions & 18 deletions js/listeners/PressListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ define( function( require ) {
var globalID = 0;

// constants - factored out to reduce memory usage, see https://github.com/phetsims/unit-rates/issues/207
var PressedEmitterIO = ActionIO( [
var PressedActionIO = ActionIO( [
{ name: 'event', type: EventIO },
{
name: 'targetNode',
Expand All @@ -50,7 +50,7 @@ define( function( require ) {
}
] );

var ReleasedEmitterIO = ActionIO( [ {
var ReleasedActionIO = ActionIO( [ {
name: 'event',
type: NullableIO( EventIO )
}, {
Expand Down Expand Up @@ -233,30 +233,30 @@ define( function( require ) {
interrupt: this.pointerInterrupt.bind( this )
};

// @private {Emitter} - Emitted on press event
// The main implementation of "press" handling is implemented as a callback to the emitter, so things are nested
// @private {Action} - Executed on press event
// The main implementation of "press" handling is implemented as a callback to the Action, so things are nested
// nicely for phet-io.
this._pressedEmitter = new Action( this.onPress.bind( this ), {
tandem: options.tandem.createTandem( 'pressedEmitter' ),
phetioDocumentation: 'Emits whenever a press occurs. The first argument when emitting can be ' +
this._pressedAction = new Action( this.onPress.bind( this ), {
tandem: options.tandem.createTandem( 'pressedAction' ),
phetioDocumentation: 'Executes whenever a press occurs. The first argument when executing can be ' +
'used to convey info about the Event.',
phetioReadOnly: options.phetioReadOnly,
phetioFeatured: options.phetioFeatured,
phetioEventType: PhetioObject.EventType.USER,
phetioType: PressedEmitterIO
phetioType: PressedActionIO
} );

// @private {Emitter} - Emitted on release event
// The main implementation of "release" handling is implemented as a callback to the emitter, so things are nested
// @private {Action} - Executed on release event
// The main implementation of "release" handling is implemented as a callback to the Action, so things are nested
// nicely for phet-io.
this._releasedEmitter = new Action( this.onRelease.bind( this ), {
tandem: options.tandem.createTandem( 'releasedEmitter' ),
phetioDocumentation: 'Emits whenever a release occurs.',
this._releasedAction = new Action( this.onRelease.bind( this ), {
tandem: options.tandem.createTandem( 'releasedAction' ),
phetioDocumentation: 'Executes whenever a release occurs.',
phetioReadOnly: options.phetioReadOnly,
phetioFeatured: options.phetioFeatured,
phetioEventType: PhetioObject.EventType.USER,

phetioType: ReleasedEmitterIO
phetioType: ReleasedActionIO
} );

// update isOverProperty (not a DerivedProperty because we need to hook to passed-in properties)
Expand Down Expand Up @@ -363,7 +363,7 @@ define( function( require ) {

sceneryLog && sceneryLog.InputListener && sceneryLog.InputListener( 'PressListener#' + this._id + ' successful press' );
sceneryLog && sceneryLog.InputListener && sceneryLog.push();
this._pressedEmitter.emit( event, targetNode || null, callback || null ); // cannot pass undefined into emit call
this._pressedAction.execute( event, targetNode || null, callback || null ); // cannot pass undefined into execute call

sceneryLog && sceneryLog.InputListener && sceneryLog.pop();

Expand All @@ -386,7 +386,7 @@ define( function( require ) {
sceneryLog && sceneryLog.InputListener && sceneryLog.InputListener( 'PressListener#' + this._id + ' release' );
sceneryLog && sceneryLog.InputListener && sceneryLog.push();

this._releasedEmitter.emit( event || null, callback || null ); // cannot pass undefined to emit call
this._releasedAction.execute( event || null, callback || null ); // cannot pass undefined to execute call

sceneryLog && sceneryLog.InputListener && sceneryLog.pop();
},
Expand Down Expand Up @@ -767,8 +767,8 @@ define( function( require ) {
this.a11yClickingProperty.dispose();
this.looksPressedProperty.dispose();

this._pressedEmitter.dispose();
this._releasedEmitter.dispose();
this._pressedAction.dispose();
this._releasedAction.dispose();

sceneryLog && sceneryLog.InputListener && sceneryLog.pop();
}
Expand Down

0 comments on commit 584f783

Please sign in to comment.