Closed pixelzoom closed 9 years ago
This pattern has been implemented and seems like it is working well. Great suggestion, @pixelzoom. We still need to implement more fundamental type coercions, but the pattern seems good.
I'm planning to add other type coercions as I need/test them, so no other work planned on this at the moment. @pixelzoom would you like to review/discuss?
Looking good, I like this much better.
In concentration-api.js, I see:
var Solute = {
...
formatForArch: function( solute ) {
return solute.componentID;
},
...
};
https://github.com/phetsims/together/issues/30 indicates that "arch" is going away, e.g. arch.start/end will be changed to together.startEvent/endEven. Should formatForArch
be formatForTogether
, or something else?
perhaps it will become formatForEventStream
Renamed above, anything else to do here?
Looks good, closing.
Notes from discussion with @samreid and @jbphet about alternatives to the "2-way binding" that appears in ConcentrationModel (see
soluteAPINameProperty
) and Solute.For together instrumentation, a couple of string parameters were added to Solute:
which results in this kind of instantiation:
These new strings don't fit with the componentID pattern used elsewhere, and (in the case of listItemComponentID) are specific to a UI component (combo box). Replace with the options.componentID pattern used elsewhere. Eg:
Then we want query parameter to look like this:
?concentrationScreen.solute=concentrationScreen.solute.drinkMix
So we need to coerce string 'concentrationScreen.solute.drinkMix' to a Solute.
In concentration.api, we'll need to add a Solute type, entries for the Solute instances, and change the type of 'concentrationScreen.solute':
Perhaps the
toTogetherString
andfromTogetherString
implementations shown above for Solute should be the defaults?We'll need something similar for other non-builtin types, e.g. Vector2, so we can do:
?concentrationScreen.concentrationMeter.probeLocation=200,300
Non-working hacks were done in branch 'together-values', see https://github.com/phetsims/beers-law-lab/issues/92.