-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unify IO type approach #44
Comments
@jonathanolson can we change Node.js to extend IOObject.js instead of Object? Notes on mixin vs inheritance are here, my recommendation is to use inheritance if feasible: #31 (comment) |
Initial investigation is promising, I committed changes to a new branch phetsims/scenery#721. This eliminates 188 lines of code from Node.js (a good trade to switch to 82 lines of code from IOObject.js) and more importantly unifies the phet-io instrumentation implementation. I tested a few instrumented nodes in Faraday's Law instance proxies and it seemed OK. Ultimately @jonathanolson will need to review, but I'm wondering if @zepumph or @pixelzoom should take a look first? |
It has my approval (just reviewed the above commit), just fix the parentheses-space formatting that got reverted. |
Since @jonathanolson approved, I'm going to skip review. |
I don't see how it will work if tandem or options are passed through the Node.mutate call, how will that get up to |
Good point @zepumph, I'll look for some cases that exhibit that pattern and look for ideas. |
Ahh, I assumed that IOObject would have something like mutate that would do a similar operation. It definitely would be inconvenient if mutate couldn't be used for it. |
@jonathanolson and I discussed and reasoned that something like: Node.call( this, IOObject.getOptions( options ) ); May be suitable to (a) assign these non-mutable values once in IOObject and (b) keep mutate logic out of IOObject. |
That may be much harder to maintain than adding some sort of logic in In terms of conventional efficiency, it adds a large correctional step to bridge the gap from phet to phet-io. I found 180 files with this regex Update: only 184 matches with Update 2: I see 345 uses of Node that call with options directly. |
It seems unfortunate that IOObject should support mutate since I know this unconventional (is crazy too strong a term?), but what about putting the |
Or maybe it would be approximately the same to have a mutate call in IOObject, but how do we enforce that it gets called exactly once? |
Mutate can get called a lot, as it is passed up the chain, but maybe we could have a |
I thought it would cause problems if it is called more than once in a hierarchy? Also agreed we could track a constructed flag in |
There are 2 calls to // PhetioObject:
if ( options ) {
this.initializePhetioObject( {}, options );
}
// Node
mutate: function( options ) {
if ( !options ) {
return this;
}
this.initializePhetioObject( { phetioType: NodeIO }, options ); So |
Btw... I'm OK with allowing |
Did you mean to move this assertion to the top of |
Ah sorry, yes - I meant to move |
OK that sounds good, I'll move it now. |
I moved the assert statement, anything else for this issue? |
Nope, that's it, closing. |
From review of IOObject in #36 (comment):
I said:
@samreid replied:
I said:
The text was updated successfully, but these errors were encountered: