-
Notifications
You must be signed in to change notification settings - Fork 174
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
feat: let users pass sync/async functions for resolving option values for headers/params #2184
Conversation
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant -- the usage and docs are both 👌
Gotta thank my colleague Windsurf for these 😎 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'm a bit weary of adding async steps in the tight loop, and would like more protection (at both the type and runtime level) agains people setting reserved params and headers
Fix #2181
This PR adds support for function-based options in the TypeScript client's params and headers. Functions can be either synchronous or asynchronous and are resolved in parallel when needed.
Common Use Cases
Design Decision
We chose to implement this using direct function values rather than a middleware/interceptor pattern (as seen in libraries like Axios or ky) for several reasons: