Closed zepumph closed 1 year ago
I was wondering if we would allow a more general remapping, like '_myValuemaps to
MyClass.someValue`? Also with the proposal above, how will it autodetect or how will we specify which ones have a different mapping?
That may be nice, but in general, and mostly for maintainability, it has been really nice to have the stateObject keys match the class fields. With or without an underscore doesn't effect that for me too much. This parallels our convention of having tandem names match variable names.
In this patch we just see if the core object has the underscore setter.
Discussed with @samreid and it seems alright and pretty simple to implement.
hasOwnProperty
check@samreid can you please review. I think it is best and easiest to get a handle of this issue in the unit test. I'm trying to be as complete as possible, but we do not support an es5 getter for an underscore-prefixed name. I feel like that is totally fine myself.
@zepumph and I reviewed and made some improvements. Anything else for this issue?
Over in https://github.com/phetsims/natural-selection/issues/327, We want to make a few Bunny fields private, with a public getter, so a private settable
_age
and the a publicget age
. It would be awesome if the defaultApplyState supported setting on the underscored key.