Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-middleware-oneshot

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-middleware-oneshot

Create a middleware

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

redux-middleware-oneshot

license npm version npm downloads Code Climate build

Create Redux actions from arbitraty sources out of middlewares.

Installation

npm install --save redux-middleware-oneshot

Usage

// In this example, we want to create someAction in redux for every
// change-event emitted by someEventEmitter
import someEventEmitter from './someEventEmitter';
import someAction from './someAction';

// And for this we simply create a new oneShot middleware
import createOneShot from 'redux-middleware-oneshot';
const myMiddleware = createOneShot((dispatch) => {
    // This function is called exactly once as soon as the first action
    // runs through redux. Perfect moment to glue things together!
    someEventEmitter.addEventListener('change', (event) => {
        dispatch(someAction(event.value));
    });
});

// Everything else is straight forward Redux ...
import { createStore, applyMiddleware, combineReducers } from 'redux';
const createStoreWithMiddleware = applyMiddleware(myMiddleware)(createStore);
const store = createStoreWithMiddleware(/* reducer */);

Todo

  • Write tests for everything!

Keywords

FAQs

Package last updated on 04 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc