Skip to content

TypeScript: How to move event handlers to separate functions #1634

Answered by jamacku
jamacku asked this question in Q&A
Discussion options

You must be logged in to vote

Just for record, there is working example:

import { Probot, Context } from 'probot';

const webhooks = [
  'pull_request.opened' as const,
  'pull_request.reopened' as const,
];

function probotCallBack(
  app: Probot,
  context: Context<typeof webhooks[number]>
) {
  if (context.isBot) {
    return;
  }

  app.log(context.payload.pull_request);
}

export = (app: Probot) => {
  app.on(webhooks, probotCallBack.bind(null, app));
};

Thanks @gr2m

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@jamacku
Comment options

@jamacku
Comment options

@gr2m
Comment options

@jamacku
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by gr2m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1633 on January 11, 2022 18:49.