w3cj / use-x

Practice implementing custom react hooks with full test suites and examples.
https://www.youtube.com/watch?v=GDXsuoisg60
MIT License
12 stars 4 forks source link

Use provided `AbortSignal` or omit it from `initialOptions` type definition #3

Open jaandrle opened 4 weeks ago

jaandrle commented 4 weeks ago

There would be better to allow use also original Abort Signal (if provided): https://github.com/w3cj/use-x/blob/ca70f15c8921a0c5ac65dbc317dfb0af1fe22b91/src/use-fetch/use-fetch.solution.ts#L95-L96

     const requestInit = (requestOptions || {}); 
     requestInit.signal = requestInit.signal ? mergeSignals(requestInit.signal, abortController.current.signal) : abortController.current.signal; 

…using https://www.npmjs.com/package/abort-utils

w3cj commented 4 weeks ago

Thanks! I will add this and a test soon. Will use the new built in AbortSignal.any() - https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static