declarative-fetch
Fetch description generator. This package does not actually execute any fetches, it simply provides an API identical to the standard fetch for producing descriptions of fetch operations that are compatible with redux-fetch middleware.
Last updated 5 years ago by ashaffer88 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install declarative-fetch 
SYNC missed versions from official npm registry.

declarative-fetch

Pure fetch function. Mimics the fetch API, but produces a javascript object describing the fetch to be performed that can be executed by libraries like redux-effects-fetch.

Installation

npm install declarative-fetch

Usage

The API is identical to HTML5 fetch, except that it returns a declarative action rather than imperatively trigger an actual fetch request. You may then pass that action into an interpreter stack, like redux-effects and it will execute your request for you. To receive the result of your request, you may decorate it with bound handlers, either by manually adding your handlers to .meta.steps on the returned action, or using a small convenience library like bind-effect.

Example

import bind from 'bind-effect'
import fetch from 'declarative-fetch'
import {createAction} from 'redux-actions'

function createUser (user) {
  return bind(fetch('/user', {
    method: 'POST',
    body: user
  }), user => userCreated)
}

const userCreated = createAction('USER_CREATED')

Current Tags

  • 0.1.13                                ...           latest (5 years ago)

14 Versions

  • 0.1.13                                ...           5 years ago
  • 0.1.12                                ...           5 years ago
  • 0.1.11                                ...           5 years ago
  • 0.1.10                                ...           5 years ago
  • 0.1.9                                ...           5 years ago
  • 0.1.8                                ...           5 years ago
  • 0.1.7                                ...           5 years ago
  • 0.1.6                                ...           5 years ago
  • 0.1.5                                ...           5 years ago
  • 0.1.4                                ...           5 years ago
  • 0.1.3                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |