program.addEventListener("GameResult", (event, game, res) => {
console.log("EVENT: ", event, game, res)
})
Sometimes it registers the event, sometimes it does not. I don't know what the hell is going on.
Here's a revised example with proper event emission and listener attachment:
// Define the event emitter function
function emitGameResultEvent() {
// ... Your event emission code here ...
}
// Add the event listener
program.addEventListener("GameResult", (event, game, res) => {
console.log("EVENT: ", event, game, res);
});
// Emit the event somewhere in your code
emitGameResultEvent();
Make sure that the event emission is happening consistently and that the listener is added before any events are emitted. If you're still facing issues, double-check the event name for any typos.
For anyone having issues with this in the future, Anchor loves everything being camel case for some reason, so even if your event everywhere is GameResult, on the event listener it should be "gameResult"