Skip to content

Conversation

@Yay295
Copy link

@Yay295 Yay295 commented Dec 17, 2024

💸 TL;DR

Devvit.addTrigger() currently creates unnecessary copies of the trigger handler for MultiTriggers.

🧪 Testing Steps / Validation

I made this change directly on the GitHub website. I haven't tested anything.

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

Signed-off-by: Yay295 <Yay295@users.noreply.github.com>
Comment on lines 405 to 408
this.addTrigger({
event: eventType,
onEvent: (event: OnTriggerRequest, context: TriggerContext) =>
(triggerDefinition.onEvent as TriggerOnEventHandler<OnTriggerRequest>)(event, context),
onEvent: triggerDefinition.onEvent,
} as any); // eslint-disable-line @typescript-eslint/no-explicit-any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop the lint too:

this.addTrigger({
  event: eventType,
  onEvent: triggerDefinition.onEvent as TriggerOnEventHandler<OnTriggerRequest>,
});

@niedzielski niedzielski requested a review from pl00h December 17, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants