@redux-actionlang/sagas

0.1.0-beta-10 • Public • Published

@redux-actionlang/sagas

Quickly Create Sagas to transform your actions to other actions and more.

The Setup

import SagaGenerator from '@redux-actionlang/sagas';
import SagaMiddleware from 'redux-saga';

const SagaGenerator = new SagaGenerator();

createSagaMiddleware().run(SagaGenerator.create());

The Usage

filter operator
  • Used to filter some actions so that you can apply map to filtered actions only.
  • Every Action will still go through reducer.
SagaGenerator.filter(action => action.type === 'MY_TYPE');
map operator
  • Apply a function on every action or every filtered action if filtered is used before.
SagaGenerator.map((action, { put }) => action);
every operator
  • Used to filter a particular action so that you can apply map to that action only.
SagaGenerator.every('LOG').map(action => console.log(action));
mapState operator
  • Injects state to your map chain.
SagaGenerator.every('LOG').mapState(state => action => console.log(state.list, action));
create
  • Create a saga to be used in Saga Middleware.
SagaGenerator.create();

Examples

  • A Simple Logger

Will log every action dispatched to the reducer.

SagaGenerator
.map(action => console.log(action))
.create();
  • Dispatch an action in response to another action.
SagaGenerator
.filter(action => action.type === 'MY_TYPE')
.map((action, { put }) => put('YOUR_TYPE'))
.create();

Package Sidebar

Install

npm i @redux-actionlang/sagas

Weekly Downloads

2

Version

0.1.0-beta-10

License

MIT

Unpacked Size

5.32 kB

Total Files

3

Last publish

Collaborators

  • raybulgarin