phetsims / axon

Axon provides powerful and concise models for interactive simulations, based on observable Properties and related patterns.
MIT License
10 stars 8 forks source link

Shouldn't be able to emit or execute on readonly Emitter. #445

Closed pixelzoom closed 5 months ago

pixelzoom commented 5 months ago

Slack#phet-io:

@pixelzoom What does phetioReadOnly: true do for an Emitter? Does it prevent calls to EmitterIO’s emit method? (edited)

@samreid I don’t see a mention of phetioReadOnly in Emitter.ts, so perhaps it has no bearing one way or the other?

@samreid Oh wait, it has invocableForReadOnlyElements: false so it would prevent.

@zepumph Look at PhetioDataHandler

@zepumph Maybe not though. It seems like we shouldn't be able to emit or execute on readonly elements.

samreid commented 5 months ago

The current implementation already prevents, right?

zepumph commented 5 months ago

Thanks for the issue so that I could double check. We are correctly disabling the ability to call Emitter.emit() and PhetioAction.execute with invocableForReadOnlyElements:false.

https://github.com/phetsims/tandem/blob/3d3456e64558d9394c6584295809731d1ae44312/js/PhetioAction.ts#L82

https://github.com/phetsims/axon/blob/af83520d5345b81f3affeddd8de70d2412583c34/js/Emitter.ts#L180

Closing