0.0.9 • Published 10 years ago

redux-io v0.0.9

Weekly downloads
875
License
MIT
Repository
github
Last release
10 years ago

redux-io

build status npm version

FSA-compliant io monad middleware for Redux.

This is based on redux-future.

npm install --save redux-io

Usage

import ioMiddleware from 'redux-io';
const createStoreWithMiddleware = applyMiddleware(
  ioMiddleware('runIO') // <- function name of the function to run the IO.
)(createStore)

Example

import { IO } from 'ramda-fantasy';

const io = IO(() => {
  document.title = "Goodbye World!";
  return { type: 'INCREMENT' };
});
store.dispatch(io);

Using in combination with redux-actions

Because it supports FSA actions, you can use redux-io in combination with redux-actions.

Example: Action creators

const io = IO(() => location.href);

const action = createAction('FSA_ACTION');
store.dispatch(action(R.map(R.toUpper, io)));

Example: Future(IO)

You can use redux-io together with redux-future.

// futureIo :: Future(IO(String))
const futureIo = new Future((rej, res) => {
  const io = IO(() => location.href);

  setTimeout(() => res(io), 2000);
});

const action = createAction('FSA_ACTION');
store.dispatch(action(futureIo));

Related

What's an IO?

Libraries

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago