Skip to content
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

Don't create extra functions for MultiTrigger handlers #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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

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
Member

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