-
Notifications
You must be signed in to change notification settings - Fork 47
Feature: Add request hooks #36
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
Conversation
@igoroctaviano this is super cool, but not easy to understand: const pipe = functions => args => functions.reduce((arg, fn) => fn(arg), args) If we go for this approach, I would suggest adding
|
Yes, and while we need to be idiomatic to the languages, it would be great if the functionality and perhaps even some of the naming were consistent with the discussion here: |
src/api.js
Outdated
@@ -187,6 +187,7 @@ class DICOMwebClient { | |||
} | |||
|
|||
if (requestInterceptors) { | |||
console.debug('yes') | |||
const metadata = { method, url }; | |||
const pipeRequestInterceptors = functions => (args) => functions.reduce((args, fn) => fn(args, metadata), args); |
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.
I would suggest adding a couple of runtime checks here
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.
Updated. Let me know if I should add more. Thanks.
@igoroctaviano could we call the option |
Sure, I took it from axios library, where they call these request interceptors but I'm fine with hooks, updated. |
@hackermd just pushed an example and updated the existent one to point to dcmjs server. |
It needs to be rebased but otherwise is this ready to be merged? |
Yes, just waiting review + merge. |
Any further comments @hackermd or should we merge? |
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 great @igoroctaviano! Just a few minor comments/suggestions. Feel free to ignore.
@pieper can you please merge this? Thanks! |
@Punzo @igoroctaviano I merged the PR. Let me know if we should draft a new release. |
yes, please! thanks! |
@Punzo @igoroctaviano I released version 0.8.0 (https://github.com/dcmjs-org/dicomweb-client/releases/tag/v0.8.0) and uploaded the new version of the package to npm (https://www.npmjs.com/package/dicomweb-client/v/0.8.0) |
Example using node-retry to add retry functionality to XHR: