New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

redux-fetch

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-fetch

Declarative data-fetching for redux

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

redux-fetch

Declarative data fetching for redux

Warning

I am developing this still as we speak, I would not expect anything in here to work at the moment, or the documentation to be up to date. I'll remove this if/when it's more stable. It's just up here for my own use and so that people can get the gist of the concept and play around with it if they want.

Usage

Add redux-fetch to your redux middleware stack (preferably at the beginning). Then, instead of imperatively calling fetch in your action creators, you can produce descriptions of the fetch you want to perform, and the middleware will execute it for you.

function createUser (user) {
  return {
    type: 'FETCH',
    payload: {
      method: 'POST',
      url: '/user',
      body: user
    },
    meta: {
      then: logUserIn
    }
  }
}

function logUserIn () {
  return {
    type: 'USER_DID_LOGIN'
  }
}

Coming soon

Less-verbose ways of doing this. Going to try to create some creators for these things, so that the API can be just like fetch. Something like:

var fetch = require('declarative-fetch')

function createUser (user) {
  return fetch('/user/', {
    method: 'post',
    body: user
  })
  .then(logUserIn)
}

Keywords

redux

FAQs

Package last updated on 17 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts