Closed KatieWoe closed 3 years ago
We discussed whether the ObservableArray remove functions should be graceful as part of https://github.com/phetsims/axon/issues/332.
Maybe add a guard that only removes drops that are in the list?
(patch is untested)
Index: js/watertower/model/WaterTowerModel.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/watertower/model/WaterTowerModel.js b/js/watertower/model/WaterTowerModel.js
--- a/js/watertower/model/WaterTowerModel.js (revision 4801c3562942091369b95b20372a8326df9a0a9c)
+++ b/js/watertower/model/WaterTowerModel.js (date 1615223075256)
@@ -327,9 +327,7 @@
this.tankFullLevelDurationProperty.value = 0;
}
- if ( this.dropsToRemove.length > 0 ) {
- this.faucetDrops.removeAll( this.dropsToRemove );
- }
+ this.faucetDrops.removeAll( this.dropsToRemove.filter( drop => this.faucetDrops.includes( drop ) ) );
this.dropsToRemove = [];
for ( let i = 0, numberOfDrops = this.waterTowerDrops.length; i < numberOfDrops; i++ ) {
Excellent!
I'll check back in on CT soon.
@jbphet’s PSA about “item not found in Array” was in https://github.com/phetsims/balancing-act/issues/126.
CT Clear