-
Notifications
You must be signed in to change notification settings - Fork 21
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(signal): remove passed signal from defautlMapOptionsToKey #83
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit aedde24:
|
@@ -16,6 +16,7 @@ | |||
|
|||
export const defaultMapOptionsToKey = (options) => { | |||
const { | |||
signal, |
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.
Can you make a unit tests that calls this function with this name and shows that it is removed.
One that would fail if this change was reverted
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.
Add unit test
README.md
Outdated
@@ -748,7 +773,7 @@ A React Hook used for dispatching asynchronous API requests. | |||
**Shape** | |||
|
|||
``` | |||
const { isLoading, data, error, run } = useFetchye(key, { defer: Boolean, mapOptionsToKey: options => options, ...fetchOptions }, fetcher); | |||
const { isLoading, data, error, run } = useFetchye(key, { signal: {}, defer: Boolean, mapOptionsToKey: options => options, ...fetchOptions }, fetcher); |
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.
signal is a fetch api that would be included as part of fetchOptions
and is not part of the useFetchye
api so should be removed from here.
const { isLoading, data, error, run } = useFetchye(key, { signal: {}, defer: Boolean, mapOptionsToKey: options => options, ...fetchOptions }, fetcher); | |
const { isLoading, data, error, run } = useFetchye(key, { defer: Boolean, mapOptionsToKey: options => options, ...fetchOptions }, fetcher); |
README.md
Outdated
@@ -765,6 +790,7 @@ const { isLoading, data, error, run } = useFetchye(key, { defer: Boolean, mapOpt | |||
|--------------------|-------------------------------------------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| | |||
| `mapOptionsToKey` | `(options: Options) => transformedOptions` | `false` | A function that maps options to the key that will become part of the cache key | | |||
| `mapKeyToCacheKey` | `(key: String, options: Options) => cacheKey: String` | `false` | A function that maps the key for use as the cacheKey allowing direct control of the cacheKey | | |||
| `signal` | `Object` | `false` | Prevents execution of `useFetchye` when desired cancelling DOM request (See [Abort Controller](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)). | |
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.
This is not a useFetchye
api so should be removed.
| `signal` | `Object` | `false` | Prevents execution of `useFetchye` when desired cancelling DOM request (See [Abort Controller](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)). | |
README.md
Outdated
@@ -337,6 +337,31 @@ const NewBookForm = () => { | |||
}; | |||
``` | |||
|
|||
### Abort Signal |
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.
Im not sure that this should be documented in this mannor, else the readme should document all of the fetch apis.
Maybe this should be framed as an example of aborting an inflight request on unmount to demonstraight that useFetchye
is just a wrapper around fetch.
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.
Update documentation based on comments.
README.md
Outdated
### Abort Signal | ||
|
||
When you neeed to abort the execution of a `useFetchye` call, you may | ||
pass a signal as an option in such way. |
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.
pass a signal as an option in such way. | |
pass a signal as an option, as demonstrated below. |
Description
add support for abortController by allowing a signal to be passed as an option
Motivation and Context
How Has This Been Tested?
tested locally passing signal as options
Types of Changes
Checklist:
What is the Impact to Developers Using Fetchye?