smapiot / piral

🚀 Framework for next generation web apps using micro frontends. ⭐️ Star to support our work!
https://piral.io
MIT License
1.68k stars 125 forks source link

Add abort signal to piral-fetch fetch options #621

Closed phildaniels closed 1 year ago

phildaniels commented 1 year ago

New Feature Proposal

Add abort signal to piral-fetch fetch options

Description

In the piral-fetch, the fetch function accepts various options, but no abort signal that can be passed per request

Background

It is generally good practice to be able to pass an abort signal to a fetch call so the call can be cancelled for whatever reason (react component unmount, cancelling a download, etc.). There is no easy way to do this with piral-fetch today as a pilet author.

Discussion

createFetchApi would be able to pass one signal for every request by every Pilet consuming the fetch api as a default, but it would be difficult to share this controller among the different pilets. I think just adding the option would be nice as an optional parameter

phildaniels commented 1 year ago

I opened a pr for this here

FlorianRappl commented 1 year ago

Thanks - yes this is indeed a good and required addition. Thanks for making the PR!

FlorianRappl commented 1 year ago

Placed in the preview. Thanks for the awesome contribution @phildaniels !

phildaniels commented 1 year ago

Thanks for accepting this, we use piral everywhere at my org so this will let me implement best practices on fetch much easier

FlorianRappl commented 1 year ago

Sure if you have any other ideas for improvements just let us know!