flash-redux

0.0.2 • Public • Published

flash-redux

Build Status Coverage Status

Redux middleware, actions and reducer for managing flash messages.

Based on rails flash etc.

Install

npm install flash-redux --save

How it works

  • flashNow and flashNext action creators allow you to add new Flash objects to your redux store via the flashReducer.
  • clearFlash action creator allows you to clear the now array.
  • flashMiddleware watches for a configurable trigger action (e.g. react-router-redux's LOCATION_CHANGE') and cycles the flash messages, so next becomes now, and next gets reset to an empty array.

How you display the messages is up to you!

API

new Flash(message, [type = 'message'])

constructor function
Flash objects have key, message and type properties.

  • key is a unique identifier generated by uuid.
  • message: String
  • type: String : default = 'message'

flashReducer

A reducer function that stores flash messages in now and next keys

flashMiddleware({ cycle })

Redux middleware that captures an action type and cycles the flashReducer keys, causing next to become now and next gets reset to an empty array.
The config object should contain a cycle key with a value of the action type to trigger the cycle event.
Typically this would be something like react-router-redux's LOCATION_CHANGE'.

flashNow(message, [messageType])

Action creator that adds a Flash object to the now array.

flashNext(message, [messageType])

Action creator that adds a Flash object to the next array.

clearFlash()

Action creator that clears the now array.

Readme

Keywords

Package Sidebar

Install

npm i flash-redux

Weekly Downloads

2

Version

0.0.2

License

ISC

Last publish

Collaborators

  • harrim91