Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/oliverjash/fun-task-fetch

fetch API implemented using the Task type, which allows cancellation amongst other things.
https://github.com/oliverjash/fun-task-fetch

fetch fetch-api functional-programming task

Last synced: 8 days ago
JSON representation

fetch API implemented using the Task type, which allows cancellation amongst other things.

Awesome Lists containing this project

README

        

# fun-task fetch

[`fetch`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API) API implemented using the [`Task`
type](https://github.com/rpominov/fun-task), which [allows cancellation amongst
other things](https://github.com/rpominov/fun-task#what-is-a-task).

This is just a proof of concept and needs more work. Example:

``` js
import cancellableFetch from './index';

const url = 'https://jsonplaceholder.typicode.com/posts'
const task = cancellableFetch(url, { method: 'GET' })

const cancel = task.run({
success(result) {
console.log('success', { result })
},
failure(result) {
console.log('failure', { result })
}
})

setTimeout(cancel, 500)
```

## Development

```
yarn
yarn build
```