-
Notifications
You must be signed in to change notification settings - Fork 8
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
investigate factoring out PhET-iO data stream responsibilities from Emitter #222
Comments
I made a straw man proposal in phetsims/scenery#928 (comment), and I'll probably start there. |
One feature that I'm not sure how it will be covered by the given proposal: what if we have an event that we require for recording and playback (and hence it has a |
Do you mean an |
For example, any of the 24 |
@samreid said:
I haven't made the proposal yet. But assuming we have a method named // If you want notification nested inside of task in the data stream
this.taskDoneEmitter = new Emitter(...);
doPhetioTask(..., (...) => {
// do the task
this.taskDoneEmitter.emit(...);
} );
// if you want notification to follow task in the data stream
this.taskDoneEmitter = new Emitter(...);
doPhetioTask(..., (...) => {
// do the task
} );
this.taskDoneEmitter.emit(...); This is more flexible than the current Emitter approach, because you can choose whether to combine or separate the task and the notification in the data stream. |
Sorry it's taken me awhile to get back to this, I've had other higher priority work. That said... In phetsims/scenery#928 (comment), I showed a brute force (untested) way to separate It’s not clear to me that If So the proposal is:
|
Currently the PhET-iO playback engine only knows how to record and play back |
I think the idea of wrapping logic in phetioEvents through methods instead of a Type is interesting and creative. I don't want to say an immediate "no" to it. My hesitation lies in how Type-focused our instrumentation process has been thus far; it isn't clear to me immediately how we will be able to support wrapper side features (like emitting the data stream) without an instrumented type associated with that logic. The clearest example to me is to support phet-io playback. Since it is all tied to instances of Emitter, it is easy for the wrapper to invoke those calls from the wrapper side. If instead that even logic was tied to a function, I'm not sure how the wrapper side would be able to get a hook to that sim code to trigger that event again. Let's talk further! From reading @pixelzoom's thoughts above, it is clear that we have adopted Emitter as the basis of the phet-io data stream in part because of convenience and its already large presence throughout the code base. There is no reason why we wouldn't be able to convert the |
Next on the checklist is:
Let me know when you want to do this. |
We're discussing on Thu 4/4/19 @ 9:30am. |
If it is going to be PhET-iO instrumented for record and playback, then it will need to be an instance. As a first pass, I'd recommend investigating renaming |
That's basically what I did (untested) in phetsims/scenery#928 (comment). |
Incremental progress from today's discussion:
|
4/4/19 meeting notes, @samreid @zepumph @pixelzoom We quickly decided to proceed with what @samreid proposed in #222 (comment):
Then @samreid and @zepumph started pairing, while I went back to work on Gas Properties. @samreid noted their progress in #222 (comment). |
If we decide that |
Self unassigning. Please assign back to me when there's something to review, or when we're ready to move to the next step in the checklist ("discuss with the dev team"). |
Expanding on #222 (comment) I'm close to a commit point. What was done
What's working:
Questions or remaining steps
UPDATE: Aqua is coming out green, so I'll commit to master and we can take next steps there. UPDATE: Notifying slack:
|
This is trying to explain both checks, in Emitter and Action. Unfortunately it is necessary at least for the granularity of assertion we are looking for. The reason is that we want to be able to assert out if ever a phetioType passes in an ActionIO (or subtype) with no args. In Emitter.js right after this check we set the
We found this to be necessary, because arrow functions don't support
I worked for awhile trying to make this simpler and easier. I pulled out lots of the validation to a separate function responsible for validating the
and
To solve these two, I did a slight amount of hackary, in which Emitter.js now specifies a function to pass to the super call BEFORE elements called within the function are defined, for example
TinyEmitter's constructor is pretty simple, and the I went through all of the checkboxes and completed them or pulled them out to separate issues. @samreid would you please take a look at my comments above, and review the pieces that mention you. I think we are safe to take this off of "blocking non phet-io publication." Let me know if you feel differently. Also feel free to remove this from blocking phet-io publication if you think it should be. What are the next steps for this issue? |
It's appropriate to have the specialized check for 0-parameter
The code has: // Extend options with values set by Action, only if there are any to set to save an object declaration.
if ( Object.keys( optionsSetByAction ).length > 0 ) {
options = _.extend( {}, options, optionsSetByAction );
}
Also there is this part: options = _.extend( {
// {ValidatorDef[]}
validators: EMPTY_ARRAY,
// {boolean} @deprecated, only to support legacy emit1, emit2, emit3 calls.
validationEnabled: true,
// phet-io - see PhetioObject.js for doc
tandem: Tandem.optional,
phetioState: false,
phetioType: ActionIOWithNoArgs, // subtypes can override with ActionIO([...]), see ActionIO.js
phetioPlayback: PhetioObject.DEFAULT_OPTIONS.phetioPlayback,
phetioEventMetadata: PhetioObject.DEFAULT_OPTIONS.phetioEventMetadata
}, options );
// Use a separate object so as to not mutate passed in options object.
const optionsSetByAction = {}; In this part, the @zepumph can you please look into those ideas? After that, it seems good to run this by @pixelzoom again. |
@samreid I removed optionsSetByAction above. I think that the way it is now is not the "best practices" since that dictates two extend calls, but I'm alright doing it this way for such a fundamental type where performance is a concern.
@pixelzoom this checkbox from the first comment is all that I can think of that remains, besides if you have anything else here. Perhaps the naming discussion in #243 was enough? Over to you for your opinion. Are we ready to close? |
I believe the intent of this item was to present/summarize the results at a dev meeting. That hasn't been done, so no, not ready to close this issue. |
Perhaps originally we meant to do this before implementing the entire thing, but instead we have implemented a (potentially) complete solution that we now want to communicate to other devs both as a PSA and place for feedback. Summary of work done here and supporting issues:
@samreid @pixelzoom @chrisklus please add to this if you feel like there is more. Assigning to developer meeting. |
We reviewed and discussed, closing. |
In phetsims/scenery#928, we discussed leveraging Emitter to add messages to the PhET-iO data stream. In phetsims/scenery#928 (comment) from 2/21/19 dev meeting, the consensus was that we'd prefer not to have this responsibility in Emitter, and it is worth taking time to investigate how that responsibility might be factored out.
@ariel-phet's instructions were:
The text was updated successfully, but these errors were encountered: