Skip to content

Commit

Permalink
remove emit1(), use emit() instead, phetsims/axon#211
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Feb 27, 2019
1 parent 18d8899 commit 81f83e0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
11 changes: 6 additions & 5 deletions js/model/CollectionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ define( function( require ) {
this.quantityProperty = new NumberProperty( 0 );

// @public {Emitter} - Called with a single molecule parameter
this.addedMoleculeEmitter = new Emitter();
this.removedMoleculeEmitter = new Emitter();
this.acceptedMoleculeCreationEmitter = new Emitter(); // triggered from KitCollection
this.addedMoleculeEmitter = new Emitter( { validationEnabled: false } );
this.removedMoleculeEmitter = new Emitter( { validationEnabled: false } );
this.acceptedMoleculeCreationEmitter = new Emitter( { validationEnabled: false } ); // triggered from KitCollection

var self = this;
this.moleculeType = moleculeType;
Expand All @@ -41,6 +41,7 @@ define( function( require ) {
}
} );
}

buildAMolecule.register( 'CollectionBox', CollectionBox );

inherit( Object, CollectionBox, {
Expand Down Expand Up @@ -75,14 +76,14 @@ define( function( require ) {
this.quantityProperty.value++;
this.molecules.push( molecule );

this.addedMoleculeEmitter.emit1( molecule );
this.addedMoleculeEmitter.emit( molecule );
},

removeMolecule: function( molecule ) {
this.quantityProperty.value--;
this.molecules.splice( this.molecules.indexOf( molecule ), 1 ); // TODO: remove() instead of splice()

this.removedMoleculeEmitter.emit1( molecule );
this.removedMoleculeEmitter.emit( molecule );
},

clear: function() {
Expand Down
9 changes: 5 additions & 4 deletions js/model/CollectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ define( function( require ) {
this.currentCollectionProperty = new Property( firstCollection );

// @public {Emitter} - Fires single parameter of {KitCollection}
this.addedCollectionEmitter = new Emitter();
this.removedCollectionEmitter = new Emitter();
this.addedCollectionEmitter = new Emitter( { validationEnabled: false } );
this.removedCollectionEmitter = new Emitter( { validationEnabled: false } );

this.layoutBounds = layoutBounds;
this.tickEmitter = tickEmitter;
this.collections = [];
this.currentIndex = 0;
this.addCollection( firstCollection );
}

buildAMolecule.register( 'CollectionList', CollectionList );

inherit( Object, CollectionList, {
Expand All @@ -46,7 +47,7 @@ define( function( require ) {
this.collections.push( collection );

// TODO: notifications before changing current collection - is this desired? may be
this.addedCollectionEmitter.emit1( collection );
this.addedCollectionEmitter.emit( collection );

// switch to collection
this.currentIndex = this.collections.indexOf( collection );
Expand All @@ -57,7 +58,7 @@ define( function( require ) {
assert && assert( this.currentCollectionProperty.value !== collection );
this.collections.splice( this.collections.indexOf( collection ), 1 ); // TODO: use remove() instead of splice()

this.removedCollectionEmitter.emit1( collection );
this.removedCollectionEmitter.emit( collection );
},

reset: function() {
Expand Down
8 changes: 4 additions & 4 deletions js/model/Kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ define( function( require ) {
this.hasMoleculesInBoxesProperty = new BooleanProperty( false ); // we record this so we know when the "reset kit" should be shown

// @public {Emitter} - Called with a single parameter molecule
this.addedMoleculeEmitter = new Emitter();
this.removedMoleculeEmitter = new Emitter();
this.addedMoleculeEmitter = new Emitter( { validationEnabled: false } );
this.removedMoleculeEmitter = new Emitter( { validationEnabled: false } );

this.buckets = buckets;
this.layoutBounds = layoutBounds;
Expand Down Expand Up @@ -320,13 +320,13 @@ define( function( require ) {
addMolecule: function( molecule ) {
this.molecules.push( molecule );

this.addedMoleculeEmitter.emit1( molecule );
this.addedMoleculeEmitter.emit( molecule );
},

removeMolecule: function( molecule ) {
this.molecules.splice( this.molecules.indexOf( molecule ), 1 ); // TODO: remove() instead of splice()

this.removedMoleculeEmitter.emit1( molecule );
this.removedMoleculeEmitter.emit( molecule );
},

/**
Expand Down
2 changes: 1 addition & 1 deletion js/model/KitCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ define( function( require ) {
kit.addedMoleculeEmitter.addListener( function( molecule ) {
_.each( self.collectionBoxes, function( box ) {
if ( box.willAllowMoleculeDrop( molecule ) ) {
box.acceptedMoleculeCreationEmitter.emit1( molecule );
box.acceptedMoleculeCreationEmitter.emit( molecule );
}
} );
} );
Expand Down
4 changes: 2 additions & 2 deletions js/screens/BAMScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ define( function( require ) {
}, options );

var createModel = function() {
var tickEmitter = new Emitter( { validValues: [ 'number' ] } ); // emits 1 parameter, timeElapsed
var tickEmitter = new Emitter( { validators: [ { valueType: 'number' } ] } ); // emits 1 parameter, timeElapsed
var model = new CollectionList( createInitialKitCollection( layoutBounds, tickEmitter ), layoutBounds, tickEmitter );
model.step = function step( timeElapsed ) {
tickEmitter.emit1( timeElapsed );
tickEmitter.emit( timeElapsed );
};
model.generateKitCollection = function generateKitCollection() {
return createKitCollection( layoutBounds, tickEmitter );
Expand Down

0 comments on commit 81f83e0

Please sign in to comment.