rnm

redux-notifications-middleware

A redux middleware to handle UI Notification events

Showing:

Popularity

Downloads/wk

6

GitHub Stars

4

Maintenance

Last Commit

5yrs ago

Contributors

1

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Build Status npm version

Notification middleware for redux

A simple middleware for handling notifications using redux store

How to use

  • install package yarn add redux-notification-middleware

Steps to add middleware

  • Add reducer
import { combineReducers } from 'redux';
import { notificationReducer } from 'redux-notification-middleware';

const reducer = combineReducers({
  // app reducers
  notification: notificationReducer,
});
  • Keep list of actions to show notifications
import C from './constants';

export default [
  'LOGIN_ACTION',
  'FETCH_PRODUCT_ACTION',
  ...
];
  • Add middleware to store with events
import { createStore, applyMiddleware } from 'redux';
import { notificationMiddleware } from 'redux-notification-middleware';
import notificationEvents from './notification_actions';
import rootReducer from './reducers';

const store = createStore(
  rootReducer,
  applyMiddleware(notificationMiddleware(notificationEvents))
);
...

In the actions we can now supply notification payload and delay

For eg:-

{
  type: 'FETCH_PRODUCT_SUCCESS',
  notificationPayload: 'Successfully fetched products',
  notificationDelay: 2000,
}

Notification states will be available in the redux store and can be consumed in any connected containers

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100