2
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.

2 Answers 2

0

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.

0

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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.