Event object passed as object within object #4667
Unanswered
trulysinclair
asked this question in
Help
Replies: 3 comments
-
Can you show where you are emitting the event? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Also, the export default class SendHealthCheckReport {
async handle(event: HealthCheckReportCreated) {
console.log(event.report)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Currently I have this setup, simply passing the report object to the dispatch method. I see where I went wrong. Instead of expecting the event, I was expected the object directly. Your snippet shows that. However, I was following the class-based listeners docs and saw export default class HealthChecksController {
async handle({ response, logger }: HttpContext) {
const report = await healthChecks.run()
if (report.isHealthy) {
logger.info('Health Check passed')
await HealthCheckReportCreated.dispatch(report)
return response.ok(report)
}
await HealthCheckReportCreated.dispatch(report)
logger.error('Health Check failed')
return response.serviceUnavailable(report)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Package version
6.12.1
Describe the bug
When setting up a class-event system for a health check report to kick off multiple actions, the
report: HealthCheckReport
is passed to class-listeners as I guess an event object instead of the flat object.This is what it should look like according to Class-based listeners
This must be done to get the expected output
Here's the output log, we see that instead of getting
report
we get what I assume to beevent.report
if we were to use a function instead of a class-based listener, referenced here.Reproduction repo
No response
Beta Was this translation helpful? Give feedback.
All reactions