Skip to content

Generalize logic to get trigger options #130

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

Merged
merged 3 commits into from
Sep 8, 2023
Merged

Generalize logic to get trigger options #130

merged 3 commits into from
Sep 8, 2023

Conversation

ejizba
Copy link
Contributor

@ejizba ejizba commented Sep 8, 2023

I always hated manually specifying these trigger properties, but I never had a cleaner way to do it and keep TypeScript happy (without resorting to any types everywhere). Well, I think I figured one out. Here's the basic idea:

// Example options
const options = { handler: () => 'hello world', connection: 'storage_APPSETTING', queueName: 'testQueue' };

// Before
const handler = options.handler;
const triggerOptions = { options.connection, options.queueName };

// After
const { handler, ...triggerOptions } = options;

I had to work some magic to combine it into one shared function, but got it figured out for everything except the cosmos one. Something about the union type CosmosDBv3TriggerOptions | CosmosDBv4TriggerOptions is throwing TypeScript off, but functionally it should be fine and I still prefer this overall.

@ejizba ejizba requested a review from hossam-nasr September 8, 2023 01:20
@ejizba ejizba merged commit f222fa1 into v4.x Sep 8, 2023
@ejizba ejizba deleted the ej/parseOptions branch September 8, 2023 21:07
@ejizba ejizba mentioned this pull request Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants