redux-streams

1.2.0 • Public • Published

redux-streams

Store middleware for Redux that let's you dispatch streams of actions.

Build Status

Installation

npm install --save redux-streams

Usage

Store

import { createStore, applyMiddleware } from 'redux';
import reduxStreams from 'redux-streams';
 
// Somewhere
import rootReducer from './reducers';
 
const store = createStore(
  rootReducer,
  applyMiddleware(reduxStreams)
);

Node Streams

import { Readable } from 'stream';
 
var stream = new Readable({ objectMode: true });
 
stream.push({ type: 'thing' });
stream.push({ type: 'thing' });
stream.push({ type: 'thing' });
stream.push({ type: 'thing' });
stream.push({ type: 'thing' });
stream.push(null);
 
store.dispatch(stream); // or store.dispatch({ type: 'some:thing', payload: stream });

Highland.js Streams

import _ from 'highland';
 
var stream = _(
  { type: 'thing' },
  { type: 'thing' },
  { type: 'thing' },
  { type: 'thing' },
  { type: 'thing' }
);
 
store.dispatch(stream); // or store.dispatch({ type: 'some:thing', payload: stream });

Untested

One idea is for streams to be able to emit streams that emit streams etc that emit actions. I'm not sure what the correct terminology for this is;

import _ from 'highland';
 
var stream = _(
  _(
    { type: '0.1' },
    { type: '0.2' },
    { type: '0.3' },
    { type: '0.4' },
    { type: '0.5' }
  ),
  _(
    { type: '1.1' },
    { type: '1.2' },
    { type: '1.3' },
    { type: '1.4' },
    { type: '1.5' }
  ),
  _(
    _(
      { type: '2.1.1' },
      { type: '2.1.2' },
      { type: '2.1.3' },
      { type: '2.1.4' },
      { type: '2.1.5' }
    ),
    _(
      { type: '2.2.1' },
      { type: '2.2.2' },
      { type: '2.2.3' },
      { type: '2.2.4' },
      { type: '2.2.5' }
    ),
  ),
);
 
store.dispatch(stream); // or store.dispatch({ type: 'some:thing', payload: stream });

Package Sidebar

Install

npm i redux-streams

Weekly Downloads

1

Version

1.2.0

License

Unlicense

Last publish

Collaborators

  • industrial