Skip to content
This repository has been archived by the owner on Aug 29, 2021. It is now read-only.
/ redux-io Public archive

FSA-compliant io monad middleware for redux

License

Notifications You must be signed in to change notification settings

stoeffel/redux-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

FSA-compliant io monad middleware for redux

Resources

License

Stars

Watchers

Forks

Packages