Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-toolbelt-saga

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-toolbelt-saga

Saga helpers for redux-toolbelt

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
2
Weekly downloads
 
Created
Source

redux-toolbelt-saga

A set of helper functions that extends 'redux-toolbelt' for usage with redux-saga.

redux-toolbelt logo

TOC

  • Installation
  • Usage
  • API Reference

Installation

The tools are available in the redux-toolbelt npm package.

npm install --save redux-toolbelt redux-toolbelt-saga redux-saga

# or

yarn add redux-toolbelt redux-toolbelt-saga redux-saga

Usage

import the functions you like to use using one of the two methods:

import {makeAsyncActionCreator} from 'redux-toolbelt'
import {makeAsyncSaga} from 'redux-toolbelt-saga'

// or

import makeAsyncActionCreator from 'redux-toolbelt/lib/makeAsyncActionCreator'
import makeAsyncSaga from 'redux-toolbelt-saga/lib/makeAsyncSaga'

API Reference

makeAsyncSaga()

Creates a saga that handles actions created using makeAsyncActionCreator.

The first argument specifies saga when to dispatch the function in the second argument.

const fetchTodos = makeAsyncActionCreator('FETCH_TODOS')

// Returns promise
const fetchTodosFromServer = ({id, url}, debug = false) => {/*...*/}

const saga = makeAsyncSaga(fetchTodos, fetchTodosFromServer)

//...
dispatch(fetchTodos({id: 100, url: 'http://google.com'}))

By default, the payload of the action is what passed to the function as it's argument.

You have two ways of changing it, using options:

const options = {
  // pass specific arguments
  args: [{id, url}],
  
  // OR
  
  // map the action to arguments using a regular or a generator function
  mapArgs: function* mapArgs(action){
    const {todosId} = action.payload
    const url = yield select(urlSelector)
    
    return [{id: todosId, url}, true]
  }
}

const saga = makeAsyncSaga(fetchTodos, fetchTodosFromServer, options)

FAQs

Package last updated on 16 Oct 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc