New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redux-reverb

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-reverb

Dead simple side-effect management for redux.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Example

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import { applyMiddleware, compose, createStore } from 'redux';
import { Provider } from 'react-redux';
import promise from 'redux-promise-middleware';
import thunk from 'redux-thunk';
import sideEffectCreator from 'redux-reverb';
import rootSideEffect from 'sideEffects';
import reducers from 'state';
import App from './App';

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const sideEffectMiddleware = sideEffectCreator(rootSideEffect);

const store = createStore(reducers, composeEnhancers(applyMiddleware(thunk, promise, sideEffectMiddleware)));

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root'),
);

sideEffects/index.js

import throttle from 'lodash/throttle';
import { SideEffect } from 'redux-reverb/lib/types';

const rootSideEffect: SideEffect = (action, previousState, currentState, dispatch) => {
  notificationSideEffect(action, previousState, currentState, dispatch);
  observeFirstName(action, previousState, currentState, dispatch);
};
export default rootSideEffect;

const notificationSideEffect: SideEffect = (action, previousState, currentState, dispatch) => {
  if (action.type === 'SET_FIRST_NAME_FULFILLED') dispatchNotification('First name successfully set', dispatch);
};

const dispatchNotification = (notificationText, dispatch) => {
  dispatch({
    type: 'PUSH_NOTIFICATION',
    payload: notificationText,
  });
  setTimeout(() => {
    dispatch({
      type: 'POP_NOTIFICATION',
    });
  }, 3000);
};

const throttledDispatchNotification = throttle((notificationText, dispatch) => {
  dispatch({
    type: 'PUSH_NOTIFICATION',
    payload: notificationText,
  });
  setTimeout(() => {
    dispatch({
      type: 'POP_NOTIFICATION',
    });
  }, 3000);
}, 2000);

const observeFirstName: SideEffect = (action, previousState, currentState, dispatch) => {
  if (previousState.user.firstName === null && currentState.user.firstName !== null) {
    console.log('user field was populated');
  }
};

FAQs

Package last updated on 12 Sep 2019

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