JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3496
  • Score
    100M100P100Q121150F
  • License MIT

TypeScript FSA utilities for redux-saga

Package Exports

  • typescript-fsa-redux-saga

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typescript-fsa-redux-saga) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

TypeScript FSA utilities for redux-saga npm version Build Status

Installation

npm install --save typescript-fsa-redux-saga

API

bindAsyncAction(actionCreators: AsyncActionCreators): HigherOrderSaga

Creates higher-order-saga that wraps target saga with async actions. Resulting saga dispatches started action once started and done/failed upon finish.

Example:

// actions.ts
import actionCreatorFactory from 'typescript-fsa';

const actionCreator = actionCreatorFactory();

// specify parameters and result shapes as generic type arguments
export const doSomething = 
  actionCreator.async<{foo: string},   // parameter type
                      {bar: number}    // result type
                     >('DO_SOMETHING');
                      
// saga.ts
import {SagaIterator} from 'redux-saga';
import {call} from 'redux-saga/effects';
import {doSomething} from './actions';
                      
const doSomethingWorker = bindAsyncAction(doSomething)(
  function* (params): SagaIterator {
    // `params` type is `{foo: string}`
    const bar = yield call(fetchSomething, params.foo);
    return {bar};
  },       
);        
              
function* mySaga(): SagaIterator {
  yield call(doSomethingWorker, {foo: 'lol'});
}