-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Emitting an event with a value of 0 produces a GameEvent instead #2418
Comments
@mattjennings Thanks for the bug! My spidey sense says this is likely bad falsey checking and providing a default |
@eonarheim yup that's what's happening here. I started working on a PR to fix this by only forcing to public emit(eventName: string, event: GameEvent<T>) {} while on public emit(eventName: string, eventObject: any) {} so while I can update |
Awesome, thanks for picking this up! My intention is to remove the I'd support widening the type in the PR to be looser on // This might need some additional thought if it winds up causing typing issues elsewhere...
public emit(eventName: string, event: GameEvent<T> | any) {} Otherwise I'm okay with a tactical change to just address the bad falsey check, and we can continue thinking/discussing the types on |
When emitting a custom event on an object, if the value is 0 it gets overwritten by a GameEvent due to this line:
Excalibur/src/engine/EventDispatcher.ts
Lines 36 to 38 in 730d621
Steps to Reproduce
Emit an event with a value of 0:
Expected Result
Value to be persisted
Actual Result
Value gets overwriten with GameEvent
Environment
Current Workaround
Create a custom GameEvent instance and emit that instead. Perhaps that is the intention, that every event should be an instance of GameEvent? If so, should
emit
throw an error if it receives something other thanundefined
or aGameEvent
?The text was updated successfully, but these errors were encountered: