Closed zepumph closed 3 years ago
@pixelzoom, would you please review the above commit. If you feel like the validateInstance
isn't actually needed, then you can delete the entire applyState function and the IOType will automatically grab it from StateSchema.defaultApplyState
.
I'm going to leave the call to validateInstance
in Bunny applyState
. It's a useful additional layer of protection again PhET-iO regressions, and it's a pattern that I've used throughout Natural Selection. But thanks for bringing this to my attention. Closing.
Over in https://github.com/phetsims/phet-io/issues/1782, I finally got to cleaning up how stateSchema duplicates much of how applyState and toStateObject are most likely implemented.
In this sim specifically, I found 2 potential problems with just blowing away the toStateObject and the applyState methods on Bunny.js
Note that the
required
calls are redundant because there is a lot of type validation that is done for anything in the state schema, both for applyState and toStateObject.