Skip to content

Experiment with fetch higher order functions and abortability

Notifications You must be signed in to change notification settings

jovdb/fetch-hof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fetch-hof

Experiment with fetch higher order functions and abortability

You can play with it here...

Some remarks about the CancelToken

I based my code on this CancelToken proposal.

What I didn't like on that proposal is that there is no handy way to get the CancelError:

  • You can wrap throwIfRequested() in a try/catch to get the exception
  • You can promise.then() to get the CancelToken, but then you have to take the asynchronicity into account.

Instead of promise , I used a subscribe function that returns an unsubscribe function. You pass an onCancel callback that will be called with the CancelError only once when cancel is called or when it is already cancelled at subscribe.

Here an example where I prefer to get the CancelError synchronous.

About

Experiment with fetch higher order functions and abortability

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published