Closed jessegreenberg closed 6 days ago
Okay it's all coming back to me. I noticed when I was setting this up, that the emitter was allowing me to pass an array of the strings without throwing an error:
I wasn't a fan of that, and wanted to be explicit that you can only pass through one parameter and it must be either 'land' or 'split'. I'm honestly not sure if it's entirely necessary, so I'm open to being convinced otherwise.
I see, thanks. I changed the pattern just a little based on examples I saw elsehwere in PhET code. I think it makes the type for ApplesAnimationState a little more clear. What do you think of this?
As a side note, I was curious why TinyEmitter was used? I usually only see that in very performance/memory critical places. Many examples in code use an Emitter
, which also supports a runtime check for the arguments passed to emit
.
const e1 = new Emitter<[ number ]>( {
parameters: [ { valueType: 'number' } ]
} );
To be honest, I don't know why PhET uses parameters
when we have TypeScript. Just pointing it out in case you want to use it.
https://github.com/phetsims/mean-share-and-balance/commit/902aa247668c1814d0f2935ef8fea0ab952ef094 is much nicer. Thank you.
Oh that's good to know. I used TinyEmitter because I thought we were supposed to use that unless we needed more of the weight from Emitter, but perhaps that validation is enough reason to do so. I'll go ahead and switch to Emitter. Thanks for investigating!
I went ahead and used Emitter
instead of TinyEmitter
. I believe this issue can be closed now.
Hey, I was curious about the type used for ApplesAnimationState.
I expected a string literal union, what is the benefit of using an array?
For #270.